From 1b48fbb57491e0c5937fe921f79bf27b826164e9 Mon Sep 17 00:00:00 2001 From: "xb.teng" Date: Wed, 26 Dec 2018 15:03:58 +0800 Subject: [PATCH] [5.0] Add protect code for curl handle Change-Id: I50e74a6bc740c20ee5a11daa7d98d1f1a621e3ee --- dali/internal/imaging/common/file-download.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/dali/internal/imaging/common/file-download.cpp b/dali/internal/imaging/common/file-download.cpp index 965226d..e384a50 100755 --- a/dali/internal/imaging/common/file-download.cpp +++ b/dali/internal/imaging/common/file-download.cpp @@ -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; } -- 2.7.4