Index: native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs.cc |
diff --git a/native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs.cc b/native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs.cc |
index f7a622fd7467226e3963461f0610f0e73d8dabd8..00d2e934aebf06ad51db64ff52ac0c4679ca527a 100644 |
--- a/native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs.cc |
+++ b/native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs.cc |
@@ -180,6 +180,8 @@ Html5Fs::Html5Fs() |
} |
Error Html5Fs::Init(const FsInitArgs& args) { |
+ pthread_cond_init(&filesystem_open_cond_, NULL); |
+ |
Error error = Filesystem::Init(args); |
if (error) |
return error; |
@@ -204,8 +206,6 @@ Error Html5Fs::Init(const FsInitArgs& args) { |
return ENOSYS; |
} |
- pthread_cond_init(&filesystem_open_cond_, NULL); |
- |
// Parse filesystem args. |
PP_FileSystemType filesystem_type = PP_FILESYSTEMTYPE_LOCALPERSISTENT; |
int64_t expected_size = 0; |
@@ -277,7 +277,8 @@ Error Html5Fs::Init(const FsInitArgs& args) { |
} |
void Html5Fs::Destroy() { |
- ppapi_->ReleaseResource(filesystem_resource_); |
+ if (ppapi_ != NULL && filesystem_resource_ != 0) |
+ ppapi_->ReleaseResource(filesystem_resource_); |
pthread_cond_destroy(&filesystem_open_cond_); |
} |