From a1613c893e478f011dbb7314449ae1b97ff16f98 Mon Sep 17 00:00:00 2001 From: Felipe Barriga Richards Date: Thu, 16 Feb 2017 13:54:12 -0300 Subject: [PATCH] binary_storage: bugfix. --- ChangeLog | 1 + binary_storage.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index a67fcb0..76347cb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,7 @@ Release 0.2 (2017-02-16) * Added support to specify source directory (not mirroring the full fs /) * Hide sidecar files by default * Added man page +* Fix crash Release 0.1 (2016-10-23) ------------------------ diff --git a/binary_storage.c b/binary_storage.c index cbe3333..e3d6202 100644 --- a/binary_storage.c +++ b/binary_storage.c @@ -43,8 +43,12 @@ void __print_on_memory_attr(struct on_memory_attr *attr) void __free_on_memory_attr(struct on_memory_attr *attr) { - free(attr->name); - free(attr->value); + if(attr->name != NULL) + free(attr->name); + + if(attr->value != NULL) + free(attr->value); + free(attr); } @@ -131,6 +135,8 @@ struct on_memory_attr *__read_on_memory_attr(size_t *offset, char *buffer, size_ { debug_print("offset=%zu\n", *offset); struct on_memory_attr *attr = malloc(sizeof(struct on_memory_attr)); + attr->name = NULL; + attr->value = NULL; //////////////////////////////// // Read name size -- 2.39.2