[5.0] Add protect code for curl handle 11/196211/1 accepted/tizen/5.0/unified/20181227.102058 submit/tizen_5.0/20181227.054344
authorxb.teng <xb.teng@samsung.com>
Wed, 26 Dec 2018 07:03:58 +0000 (15:03 +0800)
committerxb.teng <xb.teng@samsung.com>
Wed, 26 Dec 2018 07:03:58 +0000 (15:03 +0800)
Change-Id: I50e74a6bc740c20ee5a11daa7d98d1f1a621e3ee

dali/internal/imaging/common/file-download.cpp

index 965226d..e384a50 100755 (executable)
@@ -287,6 +287,8 @@ bool DownloadRemoteFileIntoMemory( const std::string& url,
                                    size_t& dataSize,
                                    size_t maximumAllowedSizeBytes )
 {
+  bool result = false;
+
   if( url.empty() )
   {
     DALI_LOG_WARNING("empty url requested \n");
@@ -297,17 +299,18 @@ bool DownloadRemoteFileIntoMemory( const std::string& url,
   // thread we need to explicity call curl_global_init() on startup from a single thread.
 
   CURL* curlHandle = curl_easy_init();
+  if ( curlHandle )
+  {
+    result = DownloadFile( curlHandle, url, dataBuffer,  dataSize, maximumAllowedSizeBytes);
 
-  bool result = DownloadFile( curlHandle, url, dataBuffer,  dataSize, maximumAllowedSizeBytes);
-
-  // clean up session
-  curl_easy_cleanup( curlHandle );
+    // clean up session
+    curl_easy_cleanup( curlHandle );
 
 #ifdef TPK_CURL_ENABLED
-  // Clean up tpkp(the module for certificate pinning) resources on Tizen
-  tpkp_curl_cleanup();
+    // Clean up tpkp(the module for certificate pinning) resources on Tizen
+    tpkp_curl_cleanup();
 #endif // TPK_CURL_ENABLED
-
+  }
   return result;
 }