diff options
author | Dmitri Pal <dpal@redhat.com> | 2010-06-09 14:02:56 -0400 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2010-06-10 10:17:38 -0400 |
commit | 95e6cf406d0796dfb4031137410baa0a165f0c2b (patch) | |
tree | 3e2058147677b544e03100fc8398da95b7a69837 | |
parent | 75b1a17efec759980a636b41e0c8144230725802 (diff) | |
download | sssd-95e6cf406d0796dfb4031137410baa0a165f0c2b.tar.gz sssd-95e6cf406d0796dfb4031137410baa0a165f0c2b.tar.xz sssd-95e6cf406d0796dfb4031137410baa0a165f0c2b.zip |
Addressing initialization issues.
Fixing bug found by coverity.
Tciket #519
-rw-r--r-- | common/collection/collection.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/common/collection/collection.c b/common/collection/collection.c index cde5db5d5..87ac32124 100644 --- a/common/collection/collection.c +++ b/common/collection/collection.c @@ -230,8 +230,12 @@ int col_allocate_item(struct collection_item **ci, const char *property, return ENOMEM; } - /* After we initialize "next" we can use delete_item() in case of error */ + /* After we initialize members we can use delete_item() in case of error */ item->next = NULL; + item->property = NULL; + item->data = NULL; + TRACE_INFO_NUMBER("About to set type to:", type); + item->type = type; /* Copy property */ item->property = strdup(property); @@ -246,7 +250,6 @@ int col_allocate_item(struct collection_item **ci, const char *property, TRACE_INFO_NUMBER("Item property length", item->property_len); TRACE_INFO_NUMBER("Item property strlen", strlen(item->property)); - /* Deal with data */ item->data = malloc(length); if (item->data == NULL) { @@ -254,11 +257,8 @@ int col_allocate_item(struct collection_item **ci, const char *property, col_delete_item(item); return ENOMEM; } - memcpy(item->data, item_data, length); - /* Deal with other properties of the item */ - TRACE_INFO_NUMBER("About to set type to:", type); - item->type = type; + memcpy(item->data, item_data, length); item->length = length; /* Make sure that data is NULL terminated in case of string */ |