binary_storage: bugfix.
authorFelipe Barriga Richards <spam@felipebarriga.cl>
Thu, 16 Feb 2017 16:54:12 +0000 (13:54 -0300)
committerFelipe Barriga Richards <spam@felipebarriga.cl>
Thu, 16 Feb 2017 17:11:09 +0000 (14:11 -0300)
ChangeLog
binary_storage.c

index a67fcb0e8f228b4aa84ec3d04a57fc8aca4b62c7..76347cb69079b8be0298060048b04f9ceaf973c4 100644 (file)
--- 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)
 ------------------------
index cbe3333c57d55deeab8a7c4d51846362ba7d0282..e3d620218cfb3927c8267cf98f2c3246d86497d5 100644 (file)
@@ -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