From 57163904547cd20b5c89bb959f75fdcf9fc5fd3d Mon Sep 17 00:00:00 2001 From: "xb.teng" Date: Wed, 26 Dec 2018 10:25:37 +0800 Subject: [PATCH] Add protect code for curl handle Change-Id: Iaad83802dcc45395759a1b08702d60d10de5b6bc --- 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