mirror of
https://github.com/radareorg/radare2.git
synced 2025-04-03 01:52:04 +00:00
A bit dsojson leak just to avoid a crash
This commit is contained in:
parent
04d040134e
commit
a5655dff9b
@ -27,9 +27,7 @@ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
/* On some platforms, <float.h> provides DBL_QNAN. */
|
||||
#ifdef STDC_HEADERS
|
||||
|
@ -350,7 +350,7 @@ static int bin_pe_init_hdr(struct PE_(r_bin_pe_obj_t)* bin) {
|
||||
time_t ts = (time_t)bin->nt_headers->file_header.TimeDateStamp;
|
||||
sdb_num_set (bin->kv, "image_file_header.TimeDateStamp",
|
||||
bin->nt_headers->file_header.TimeDateStamp, 0);
|
||||
gettimeofday (&tv, &tz);
|
||||
gettimeofday (&tv, (void*)&tz);
|
||||
gmtoff = (int)(tz.tz_minuteswest*60); // in seconds
|
||||
ts += gmtoff;
|
||||
timestr = r_str_chop (strdup (ctime (&ts)));
|
||||
|
@ -660,29 +660,32 @@ R_API char * r_bin_java_unmangle (const char *flags, const char *name, const cha
|
||||
}
|
||||
|
||||
R_API DsoJsonObj * r_bin_java_get_bin_obj_json (RBinJavaObj *bin) {
|
||||
DsoJsonObj *imports_list = r_bin_java_get_import_json_definitions (bin),
|
||||
*fields_list = r_bin_java_get_field_json_definitions (bin),
|
||||
*methods_list = r_bin_java_get_method_json_definitions (bin),
|
||||
//*interfaces_list = r_bin_java_get_interface_json_definitions (bin),
|
||||
*class_dict = r_bin_java_get_class_info_json (bin);
|
||||
DsoJsonObj *imports_list = r_bin_java_get_import_json_definitions (bin);
|
||||
DsoJsonObj *fields_list = r_bin_java_get_field_json_definitions (bin);
|
||||
DsoJsonObj *methods_list = r_bin_java_get_method_json_definitions (bin);
|
||||
//*interfaces_list = r_bin_java_get_interface_json_definitions (bin);
|
||||
DsoJsonObj *class_dict = r_bin_java_get_class_info_json (bin);
|
||||
|
||||
char *res = dso_json_obj_to_str (methods_list);
|
||||
//eprintf ("Resulting methods json: \n%s\n", res);
|
||||
free (res);
|
||||
dso_json_dict_insert_str_key_obj (class_dict, "methods", methods_list);
|
||||
dso_json_list_free (methods_list);
|
||||
//dso_json_list_free (methods_list);
|
||||
dso_json_obj_del (methods_list);
|
||||
|
||||
res = dso_json_obj_to_str (fields_list);
|
||||
//eprintf ("Resulting fields json: \n%s\n", res);
|
||||
free (res);
|
||||
dso_json_dict_insert_str_key_obj (class_dict, "fields", fields_list);
|
||||
dso_json_list_free (fields_list);
|
||||
//dso_json_list_free (fields_list);
|
||||
dso_json_obj_del (fields_list);
|
||||
|
||||
res = dso_json_obj_to_str (imports_list);
|
||||
//eprintf ("Resulting imports json: \n%s\n", res);
|
||||
free (res);
|
||||
dso_json_dict_insert_str_key_obj (class_dict, "imports", imports_list);
|
||||
dso_json_list_free (imports_list);
|
||||
//dso_json_list_free (imports_list);
|
||||
dso_json_obj_del (imports_list);
|
||||
|
||||
//res = dso_json_obj_to_str (interfaces_list);
|
||||
//eprintf ("Resulting interfaces json: \n%s\n", res);
|
||||
@ -722,9 +725,8 @@ R_API DsoJsonObj * r_bin_java_get_import_json_definitions(RBinJavaObj *bin) {
|
||||
|
||||
R_API DsoJsonObj * r_bin_java_get_class_info_json(RBinJavaObj *bin) {
|
||||
RList *classes = r_bin_java_get_classes (bin);
|
||||
DsoJsonObj *interfaces_list = dso_json_list_new (),
|
||||
*class_info_dict = dso_json_dict_new ();
|
||||
|
||||
DsoJsonObj *interfaces_list = dso_json_list_new ();
|
||||
DsoJsonObj *class_info_dict = dso_json_dict_new ();
|
||||
RBinClass *class_ = r_list_get_n (classes, 0);
|
||||
|
||||
if (class_) {
|
||||
@ -773,7 +775,8 @@ R_API DsoJsonObj * r_bin_java_get_class_info_json(RBinJavaObj *bin) {
|
||||
}
|
||||
dso_json_dict_insert_str_key_obj (class_info_dict, "interfaces", interfaces_list);
|
||||
r_list_free (classes);
|
||||
dso_json_list_free (interfaces_list);
|
||||
//dso_json_list_free (interfaces_list);
|
||||
dso_json_obj_del (interfaces_list);
|
||||
return class_info_dict;
|
||||
}
|
||||
|
||||
|
@ -116,21 +116,21 @@ R_API char * dso_json_obj_to_str (DsoJsonObj * dso_obj) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
R_API void dso_json_obj_del (void *dso_objv) {
|
||||
DsoJsonObj *dso_obj = ((DsoJsonObj *) dso_objv);
|
||||
if (dso_objv) {
|
||||
switch (dso_obj->info->type) {
|
||||
case DSO_JSON_NULL: /*do nothing */ break;
|
||||
case DSO_JSON_NUM: dso_json_num_free (dso_obj->val._num); break;
|
||||
case DSO_JSON_STR: dso_json_str_free (dso_obj->val._str); break;
|
||||
case DSO_JSON_LIST: dso_json_list_free (dso_obj->val._list); break;
|
||||
case DSO_JSON_DICT: dso_json_dict_free (dso_obj->val._dict); break;
|
||||
case DSO_JSON_DICT_ENTRY: dso_json_dict_entry_free (dso_obj->val._dict_entry); break;
|
||||
default: break;
|
||||
}
|
||||
memset (dso_obj, 0, sizeof (DsoJsonObj));
|
||||
free (dso_obj);
|
||||
R_API void dso_json_obj_del (DsoJsonObj *dso_obj) {
|
||||
if (!dso_obj) return;
|
||||
switch (dso_obj->info->type) {
|
||||
case DSO_JSON_NULL: /*do nothing */ break;
|
||||
case DSO_JSON_NUM: dso_json_num_free (dso_obj->val._num); break;
|
||||
case DSO_JSON_STR: dso_json_str_free (dso_obj->val._str); break;
|
||||
case DSO_JSON_LIST: dso_json_list_free (dso_obj); break; //->val._list); break;
|
||||
case DSO_JSON_DICT: dso_json_dict_free (dso_obj->val._dict); break;
|
||||
case DSO_JSON_DICT_ENTRY: dso_json_dict_entry_free (dso_obj->val._dict_entry); break;
|
||||
default: break;
|
||||
}
|
||||
#if 0
|
||||
//memset (dso_obj, 0, sizeof (DsoJsonObj));
|
||||
free (dso_obj);
|
||||
#endif
|
||||
}
|
||||
|
||||
static const DsoJsonInfo* get_type_info (unsigned int type) {
|
||||
@ -420,7 +420,7 @@ R_API DsoJsonObj * dso_json_list_new () {
|
||||
x->info = get_type_info (DSO_JSON_LIST);
|
||||
x->val._list = json_new0 (sizeof (DsoJsonList));
|
||||
if (x->val._list) {
|
||||
x->val._list->json_list = r_list_newf (dso_json_obj_del);
|
||||
x->val._list->json_list = r_list_newf ((RListFree)dso_json_obj_del);
|
||||
} else {
|
||||
R_FREE (x);
|
||||
}
|
||||
@ -428,14 +428,11 @@ R_API DsoJsonObj * dso_json_list_new () {
|
||||
return x;
|
||||
}
|
||||
|
||||
R_API void dso_json_list_free (void *y) {
|
||||
DsoJsonList *x = (DsoJsonList *)y;
|
||||
if (x) {
|
||||
if (x->json_list) {
|
||||
r_list_free (x->json_list);
|
||||
x->json_list = NULL;
|
||||
}
|
||||
free (x);
|
||||
R_API void dso_json_list_free (DsoJsonObj *x) {
|
||||
if (!x) return;
|
||||
if (x->val._list && x->val._list->json_list) {
|
||||
r_list_free (x->val._list->json_list);
|
||||
x->val._list->json_list = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@ -480,7 +477,7 @@ R_API DsoJsonObj * dso_json_dict_new () {
|
||||
if (x) {
|
||||
x->info = get_type_info (DSO_JSON_DICT);
|
||||
x->val._dict = json_new0 (sizeof (DsoJsonObj));
|
||||
x->val._dict->json_dict = r_list_newf (dso_json_obj_del);
|
||||
x->val._dict->json_dict = r_list_newf ((RListFree)dso_json_obj_del);
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
@ -12,12 +12,12 @@ typedef struct dso_json_info_t {
|
||||
} DsoJsonInfo;
|
||||
|
||||
typedef enum {
|
||||
DSO_JSON_NULL = 0x00,
|
||||
DSO_JSON_NUM = 0x01,
|
||||
DSO_JSON_STR = 0x02,
|
||||
DSO_JSON_LIST = 0x03,
|
||||
DSO_JSON_DICT = 0x04,
|
||||
DSO_JSON_DICT_ENTRY = 0x05,
|
||||
DSO_JSON_NULL = 1,
|
||||
DSO_JSON_NUM,
|
||||
DSO_JSON_STR,
|
||||
DSO_JSON_LIST,
|
||||
DSO_JSON_DICT,
|
||||
DSO_JSON_DICT_ENTRY,
|
||||
DSO_JSON_END = 0xFF,
|
||||
} DSO_JSON_TYPES;
|
||||
|
||||
@ -59,8 +59,7 @@ typedef struct basic_json_t {
|
||||
|
||||
R_API ut8 dso_json_char_needs_hexing ( ut8 b);
|
||||
|
||||
R_API void dso_json_obj_del (void *dso_objv);
|
||||
|
||||
R_API void dso_json_obj_del (DsoJsonObj *dso_obj);
|
||||
R_API char * dso_json_obj_to_str (DsoJsonObj * dso_obj);
|
||||
R_API DsoJsonObj * dso_json_null_new (void);
|
||||
R_API void dso_json_null_free (void *x);
|
||||
@ -87,7 +86,7 @@ R_API int dso_json_dict_entry_value_set_empty_list (DsoJsonObj *entry_obj);
|
||||
R_API int dso_json_dict_entry_value_set_obj (DsoJsonObj *entry_obj, DsoJsonObj *obj);
|
||||
|
||||
R_API DsoJsonObj * dso_json_list_new (void);
|
||||
R_API void dso_json_list_free (void *y);
|
||||
R_API void dso_json_list_free (DsoJsonObj *x);
|
||||
R_API int dso_json_list_append (DsoJsonObj *list_obj, DsoJsonObj *y);
|
||||
R_API int dso_json_list_append_str (DsoJsonObj *list_obj, char *y);
|
||||
R_API int dso_json_list_append_num (DsoJsonObj *list_obj, ut64 y);
|
||||
|
Loading…
x
Reference in New Issue
Block a user