From 1cd8ac2bb25a0ed72170fbefd815a9e452830afb Mon Sep 17 00:00:00 2001 From: Adubbz Date: Sat, 27 Jul 2019 00:20:56 +1000 Subject: [PATCH] Fix a potential data abort when flushing the placeholder accessor cache --- .../ncm/source/impl/ncm_placeholder_accessor.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/stratosphere/ncm/source/impl/ncm_placeholder_accessor.cpp b/stratosphere/ncm/source/impl/ncm_placeholder_accessor.cpp index d03327421..e495ee624 100644 --- a/stratosphere/ncm/source/impl/ncm_placeholder_accessor.cpp +++ b/stratosphere/ncm/source/impl/ncm_placeholder_accessor.cpp @@ -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;