summaryrefslogtreecommitdiff
path: root/src/format/dex
diff options
context:
space:
mode:
Diffstat (limited to 'src/format/dex')
-rw-r--r--src/format/dex/dex-int.c4
-rw-r--r--src/format/dex/method.c9
2 files changed, 10 insertions, 3 deletions
diff --git a/src/format/dex/dex-int.c b/src/format/dex/dex-int.c
index 8f5b408..5628e6b 100644
--- a/src/format/dex/dex-int.c
+++ b/src/format/dex/dex-int.c
@@ -454,6 +454,7 @@ bool read_dex_class_data_item(const GDexFormat *format, off_t *pos, class_data_i
if (result && item->static_fields_size > 0)
{
item->static_fields = (encoded_field *)calloc(item->static_fields_size, sizeof(encoded_field));
+ if (item->static_fields == NULL) item->static_fields_size = 0;
for (i = 0; i < item->static_fields_size && result; i++)
result = read_dex_encoded_field(format, pos, &item->static_fields[i]);
@@ -463,6 +464,7 @@ bool read_dex_class_data_item(const GDexFormat *format, off_t *pos, class_data_i
if (result && item->instance_fields_size > 0)
{
item->instance_fields = (encoded_field *)calloc(item->instance_fields_size, sizeof(encoded_field));
+ if (item->instance_fields == NULL) item->instance_fields_size = 0;
for (i = 0; i < item->instance_fields_size && result; i++)
result = read_dex_encoded_field(format, pos, &item->instance_fields[i]);
@@ -472,6 +474,7 @@ bool read_dex_class_data_item(const GDexFormat *format, off_t *pos, class_data_i
if (result && item->direct_methods_size > 0)
{
item->direct_methods = (encoded_method *)calloc(item->direct_methods_size, sizeof(encoded_method));
+ if (item->direct_methods == NULL) item->direct_methods_size = 0;
for (i = 0; i < item->direct_methods_size && result; i++)
result = read_dex_encoded_method(format, pos, &item->direct_methods[i]);
@@ -481,6 +484,7 @@ bool read_dex_class_data_item(const GDexFormat *format, off_t *pos, class_data_i
if (result && item->virtual_methods_size > 0)
{
item->virtual_methods = (encoded_method *)calloc(item->virtual_methods_size, sizeof(encoded_method));
+ if (item->virtual_methods == NULL) item->virtual_methods_size = 0;
for (i = 0; i < item->virtual_methods_size && result; i++)
result = read_dex_encoded_method(format, pos, &item->virtual_methods[i]);
diff --git a/src/format/dex/method.c b/src/format/dex/method.c
index 4888c89..ce4d8dd 100644
--- a/src/format/dex/method.c
+++ b/src/format/dex/method.c
@@ -135,6 +135,12 @@ GDexMethod *g_dex_method_new(const GDexFormat *format, const encoded_method *see
if (!read_dex_code_item(format, &offset, &item))
return NULL;
+ *last += seed->method_idx_diff;
+ routine = get_routine_from_dex_pool(format, *last);
+
+ if (routine == NULL) return NULL;
+
+
result = g_object_new(G_TYPE_DEX_METHOD, NULL);
result->body = item;
@@ -143,9 +149,6 @@ GDexMethod *g_dex_method_new(const GDexFormat *format, const encoded_method *see
//printf(" code size :: %d\n", item.insns_size);
- *last += seed->method_idx_diff;
- routine = get_routine_from_dex_pool(format, *last);
-
printf(" method idx :: %lld\n", *last);