Fix svace issue (file-download writter null check) 94/284794/1
authorEunki Hong <eunkiki.hong@samsung.com>
Sun, 27 Nov 2022 07:12:00 +0000 (16:12 +0900)
committerEunki Hong <eunkiki.hong@samsung.com>
Sun, 27 Nov 2022 07:12:00 +0000 (16:12 +0900)
Change-Id: I35729eb2d6cc647eedb953fc7d9aaf70c3ae84a7
Signed-off-by: Eunki Hong <eunkiki.hong@samsung.com>
dali/internal/imaging/common/file-download.cpp

index 278375d..2940300 100644 (file)
@@ -121,10 +121,11 @@ CURLcode DownloadFileDataWithSize(CURL* curlHandle, Dali::Vector<uint8_t>& dataB
   // create
   Dali::Internal::Platform::FileWriter fileWriter(dataBuffer, dataSize);
   FILE*                                dataBufferFilePointer = fileWriter.GetFile();
-  setbuf(dataBufferFilePointer, NULL); // Turn buffering off
 
   if(NULL != dataBufferFilePointer)
   {
+    setbuf(dataBufferFilePointer, NULL); // Turn buffering off
+
     // we only want the body which contains the file data
     curl_easy_setopt(curlHandle, CURLOPT_HEADER, EXCLUDE_HEADER);
     curl_easy_setopt(curlHandle, CURLOPT_NOBODY, INCLUDE_BODY);
@@ -136,6 +137,12 @@ CURLcode DownloadFileDataWithSize(CURL* curlHandle, Dali::Vector<uint8_t>& dataB
     // synchronous request of the body data
     result = curl_easy_perform(curlHandle);
   }
+  else
+  {
+    DALI_LOG_ERROR("Fail to open buffer writter with size : %zu!\n", dataSize);
+    // @todo : Need to check that is it correct error code?
+    result = CURLE_READ_ERROR;
+  }
   return result;
 }