Browse Source

Bugfix: Wait to release JSON result in case of JSON-RPC error until we've logged the error

Luke Dashjr 13 years ago
parent
commit
cee65c5d58
1 changed files with 1 additions and 2 deletions
  1. 1 2
      util.c

+ 1 - 2
util.c

@@ -152,8 +152,6 @@ json_t *json_rpc_call(const char *url, const char *userpass, const char *rpc_req
 	    (err_val && !json_is_null(err_val))) {
 	    (err_val && !json_is_null(err_val))) {
 		char *s;
 		char *s;
 
 
-		json_decref(val);
-
 		if (err_val)
 		if (err_val)
 			s = json_dumps(err_val, JSON_INDENT(3));
 			s = json_dumps(err_val, JSON_INDENT(3));
 		else
 		else
@@ -162,6 +160,7 @@ json_t *json_rpc_call(const char *url, const char *userpass, const char *rpc_req
 		fprintf(stderr, "JSON-RPC call failed: %s\n", s);
 		fprintf(stderr, "JSON-RPC call failed: %s\n", s);
 
 
 		free(s);
 		free(s);
+		json_decref(val);
 			
 			
 		goto err_out;
 		goto err_out;
 	}
 	}