summaryrefslogtreecommitdiff
path: root/src/format/dex
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2010-06-14 23:39:03 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2010-06-14 23:39:03 (GMT)
commit1e2aada1204d3da43fe075478df5bfaaece937b0 (patch)
tree99eb321808ddcc0364928adf9266f32a201d2b59 /src/format/dex
parentaf7d2ea327d27200ad151d3e1ba0ee6d51b1ff62 (diff)
Made the program stronger by handling more errors.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@167 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
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);