[libfko] always call free() from zero_free() on all non-NULL buf pointers
authorMichael Rash <mbr@cipherdyne.org>
Thu, 11 Jul 2013 03:09:41 +0000 (23:09 -0400)
committerMichael Rash <mbr@cipherdyne.org>
Thu, 11 Jul 2013 03:09:41 +0000 (23:09 -0400)
lib/fko_util.c

index 8d299fa..e70e6ea 100644 (file)
@@ -404,9 +404,15 @@ int zero_free(char *buf, int len)
 {
     int res = FKO_SUCCESS;
 
-    if(buf == NULL || len == 0)
+    if(buf == NULL)
         return res;
 
+    if(len == 0)
+    {
+        free(buf);  /* always free() if buf != NULL */
+        return res;
+    }
+
     res = zero_buf(buf, len);
 
     free(buf);