@@ -321,7 +321,6 @@ int network_set_sqlite_result (sqlite3_context *context, NETWORK_RESULT *result)
321321 break ;
322322 }
323323
324- network_result_cleanup (result );
325324 return rc ;
326325}
327326
@@ -339,10 +338,10 @@ int network_download_changes (sqlite3_context *context, const char *download_url
339338 int rc = SQLITE_OK ;
340339 if (result .code == CLOUDSYNC_NETWORK_BUFFER ) {
341340 rc = cloudsync_payload_apply (context , result .buffer , (int )result .blen );
342- network_result_cleanup (& result );
343341 } else {
344342 rc = network_set_sqlite_result (context , & result );
345343 }
344+ network_result_cleanup (& result );
346345
347346 return rc ;
348347}
@@ -552,7 +551,6 @@ bool network_compute_endpoints (sqlite3_context *context, network_data *data, co
552551void network_result_to_sqlite_error (sqlite3_context * context , NETWORK_RESULT res , const char * default_error_message ) {
553552 sqlite3_result_error (context , ((res .code == CLOUDSYNC_NETWORK_ERROR ) && (res .buffer )) ? res .buffer : default_error_message , -1 );
554553 sqlite3_result_error_code (context , SQLITE_ERROR );
555- network_result_cleanup (& res );
556554}
557555
558556// MARK: - Init / Cleanup -
@@ -707,6 +705,7 @@ int cloudsync_network_send_changes_internal (sqlite3_context *context, int argc,
707705 if (res .code != CLOUDSYNC_NETWORK_BUFFER ) {
708706 cloudsync_memory_free (blob );
709707 network_result_to_sqlite_error (context , res , "cloudsync_network_send_changes unable to receive upload URL" );
708+ network_result_cleanup (& res );
710709 return SQLITE_ERROR ;
711710 }
712711
@@ -780,6 +779,7 @@ int cloudsync_network_check_internal(sqlite3_context *context) {
780779 rc = network_set_sqlite_result (context , & result );
781780 }
782781
782+ network_result_cleanup (& result );
783783 return rc ;
784784}
785785
0 commit comments