From 7fc72f3ae149e416a297ef1f55c09271056e98f1 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 20 Mar 2014 10:38:27 +0100 Subject: [PATCH] Fix yaz_use_attribute_create (uninit memory) Bug introduced by recent commit 5350317640042c3507172d28d142795. --- src/srwutil.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/srwutil.c b/src/srwutil.c index 83665d4..493a7a3 100644 --- a/src/srwutil.c +++ b/src/srwutil.c @@ -45,7 +45,7 @@ Z_AttributeElement *yaz_string_element_create(ODR o, int type, Z_AttributeElement *element = (Z_AttributeElement*) odr_malloc(o, sizeof(*element)); element->attributeType = odr_intdup(o, type); - element->attributeSet = odr_nullval(); + element->attributeSet = 0; element->which = Z_AttributeValue_complex; element->value.complex = (Z_ComplexAttribute *) odr_malloc(o, sizeof(Z_ComplexAttribute)); @@ -65,12 +65,11 @@ Z_AttributeList *yaz_use_attribute_create(ODR o, const char *name) { Z_AttributeList *attributes = (Z_AttributeList *) odr_malloc(o, sizeof(*attributes)); - Z_AttributeElement **elements = (Z_AttributeElement**) - odr_malloc(o, attributes->num_attributes * sizeof(*elements)); - elements[0] = yaz_string_element_create(o, 1, name); attributes->num_attributes = 1; - attributes->attributes = elements; + attributes->attributes = (Z_AttributeElement**) + odr_malloc(o, sizeof(*attributes->attributes)); + attributes->attributes[0] = yaz_string_element_create(o, 1, name); return attributes; } -- 1.7.10.4