Fix static analysis issue 69/211769/3
authorIlho Kim <ilho159.kim@samsung.com>
Fri, 9 Aug 2019 04:17:46 +0000 (13:17 +0900)
committerIlho Kim <ilho159.kim@samsung.com>
Tue, 13 Aug 2019 04:03:56 +0000 (13:03 +0900)
Fix NULL Pointer dereference when memory allocation fails

Change-Id: Id988582b90da46dffb799ac17414b3e9b2a7cdd9
Signed-off-by: Ilho Kim <ilho159.kim@samsung.com>
src/lib/tpk_archive_info.cc

index 7680a5559659b7dcef16cbf4be06db7e777918f5..9437413ef77afab79301c93c2ce356bc9a1b0c74 100644 (file)
@@ -224,6 +224,10 @@ bool ReadIcon(const bf::path& icon, const bf::path& tmp_dir,
     return false;
 
   char* buf = static_cast<char*>(malloc(sizeof(char) * len));
+  if (!buf) {
+    LOG(ERROR) << "Out of memory";
+    return false;
+  }
 
   LOG(INFO) << "Reading icon file, " << len << " bytes";
   ifs.read(buf, len);