Fix a potential data abort when flushing the placeholder accessor cache

This commit is contained in:
Adubbz 2019-07-27 00:20:56 +10:00
parent 1b99cd6b4d
commit 1cd8ac2bb2

View file

@ -206,12 +206,15 @@ namespace sts::ncm::impl {
if (cache == nullptr) {
cache = &this->caches[0];
/* Flush and close */
fsync(fileno(cache->handle));
fclose(cache->handle);
/* Flush and close any handles. */
if (cache->handle) {
fsync(fileno(cache->handle));
fclose(cache->handle);
}
cache->id = InvalidUuid;
}
/* Cache the new placeholder id and its file handle. */
cache->id = placeholder_id;
cache->handle = handle;
cache->counter = this->cur_counter;