free the tokener and json before all return statements

This commit is contained in:
c6226 2015-12-05 17:47:56 +08:00
parent 209dbc95e2
commit acdc0973c8

View File

@ -428,6 +428,8 @@ int httpfs_permission_to_string(int permission, char* perm_string)
static rsRetVal
httpfs_parse_exception(char* buf, int length, httpfs_json_remote_exception* jre)
{
DEFiRet;
if (!length) {
return RS_RET_JSON_PARSE_ERR;
}
@ -439,11 +441,11 @@ httpfs_parse_exception(char* buf, int length, httpfs_json_remote_exception* jre)
json = json_tokener_parse_ex(jt, buf, length);
if (!json_object_is_type(json, json_type_object)) {
// not an object ?
return RS_RET_JSON_PARSE_ERR;
ABORT_FINALIZE(RS_RET_JSON_PARSE_ERR);
}
if (!json_object_object_get_ex(json, "RemoteException", &json)) {
return RS_RET_JSON_PARSE_ERR;
ABORT_FINALIZE(RS_RET_JSON_PARSE_ERR);
}
struct json_object *jobj;
@ -459,12 +461,15 @@ httpfs_parse_exception(char* buf, int length, httpfs_json_remote_exception* jre)
json_object_object_get_ex(json, "message", &jobj);
strncpy(jre->message, (char*) json_object_get_string(jobj), json_object_get_string_len(jobj));
finalize_it:
if(jt != NULL)
json_tokener_free(jt);
if(json != NULL)
json_object_put(json);
return RS_RET_OK;
RETiRet;
}
#if 0
/**
* Make a new directory