summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitri Pal <dpal@redhat.com>2010-06-09 14:02:56 -0400
committerStephen Gallagher <sgallagh@redhat.com>2010-06-10 10:17:22 -0400
commit19e3e0bb949ccf10bc6e83cd81cbca294a99e747 (patch)
tree7a0c88254c7d1bc0d11657c7db0750365117a49d
parenta1445466e298085a4a1f847cf50b6d2f8f007a9a (diff)
downloadsssd-19e3e0bb949ccf10bc6e83cd81cbca294a99e747.tar.gz
sssd-19e3e0bb949ccf10bc6e83cd81cbca294a99e747.tar.xz
sssd-19e3e0bb949ccf10bc6e83cd81cbca294a99e747.zip
Addressing initialization issues.
Fixing bug found by coverity. Tciket #519
-rw-r--r--common/collection/collection.c12
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 */