[Forensics-changes] [yara] 144/368: Implemented @plusvic's suggestions to #392 and rm'd unused variable.

Hilko Bengen bengen at moszumanska.debian.org
Sat Jul 1 10:30:21 UTC 2017


This is an automated email from the git hooks/post-receive script.

bengen pushed a commit to annotated tag v3.5.0
in repository yara.

commit f8d9c56f899a78b6f2a7ac2054fb5f7b9e5c7076
Author: AB <AB at null.com>
Date:   Sun Jan 10 09:15:40 2016 -0800

    Implemented @plusvic's suggestions to #392 and rm'd unused variable.
---
 libyara/object.c | 51 ++++++++-------------------------------------------
 1 file changed, 8 insertions(+), 43 deletions(-)

diff --git a/libyara/object.c b/libyara/object.c
index c375e19..ac4001b 100644
--- a/libyara/object.c
+++ b/libyara/object.c
@@ -545,7 +545,6 @@ int yr_object_copy(
   YR_OBJECT* copy;
   YR_OBJECT* o;
 
-  YR_ARRAY_ITEMS* array_items;
   YR_STRUCTURE_MEMBER* structure_member;
   YR_OBJECT_FUNCTION* func;
   YR_OBJECT_FUNCTION* func_copy;
@@ -609,56 +608,22 @@ int yr_object_copy(
       break;
 
     case OBJECT_TYPE_ARRAY:
-      ;
-      YR_OBJECT_ARRAY *array = (YR_OBJECT_ARRAY *) object;
-      YR_OBJECT *array_prototype_item;
-
-      yr_object_copy(array->prototype_item, &array_prototype_item);
-
-      ((YR_OBJECT_ARRAY *)copy)->prototype_item = array_prototype_item;
-
-      if (array->items == NULL)
-      {
-        uint8_t init_size = 64;
-
-        array->items = (YR_ARRAY_ITEMS*) yr_malloc(
-            sizeof(YR_ARRAY_ITEMS) + init_size * sizeof(YR_OBJECT*));
 
-        if (array->items == NULL)
-          return ERROR_INSUFICIENT_MEMORY;
+      yr_object_copy(
+        ((YR_OBJECT_ARRAY *) object)->prototype_item,
+        &o);
 
-        memset(array->items->objects, 0, init_size * sizeof(YR_OBJECT*));
-
-        array->items->count = 0;
-      }
-
-      array_items = ((YR_OBJECT_ARRAY*) object)->items;
-
-      for (i = 0; i < array_items->count; i++)
-      {
-        if (array_items->objects[i] != NULL)
-        {
-          FAIL_ON_ERROR_WITH_CLEANUP(
-              yr_object_copy(array_items->objects[i], &o),
-              yr_object_destroy(copy));
-
-          FAIL_ON_ERROR_WITH_CLEANUP(
-                yr_object_array_set_item(copy, o, i),
-                yr_free(o);
-                yr_object_destroy(copy));
-        }
-      }
+      ((YR_OBJECT_ARRAY *)copy)->prototype_item = o;
 
       break;
 
     case OBJECT_TYPE_DICTIONARY:
-      ;
-      YR_OBJECT_DICTIONARY *dict = (YR_OBJECT_DICTIONARY *) object;
-      YR_OBJECT *dictionary_prototype_item;
 
-      yr_object_copy(dict->prototype_item, &dictionary_prototype_item);
+      yr_object_copy(
+        ((YR_OBJECT_DICTIONARY *) object)->prototype_item,
+        &o);
 
-      ((YR_OBJECT_DICTIONARY *)copy)->prototype_item = dictionary_prototype_item;
+      ((YR_OBJECT_DICTIONARY *)copy)->prototype_item = o;
 
       break;
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/forensics/yara.git



More information about the forensics-changes mailing list