Commit Diff


commit - 4ec14e60ca0e283293b2dc7fafe977fa7baf469e
commit + 57ebf19f2d3fab10b9053e7c865cbd251e1ded0d
blob - eb235b008a747da54825c94d958d96e8f0080399
blob + b744f0fb0a59eddc6866bcc61f31ca889be8cc48
--- lib/buf.c
+++ lib/buf.c
@@ -69,8 +69,10 @@ buf_alloc(size_t len)
 	/* Postpone creation of zero-sized buffers */
 	if (len > 0) {
 		b->cb_buf = calloc(1, len);
-		if (b->cb_buf == NULL)
+		if (b->cb_buf == NULL) {
+			free(b);
 			return NULL;
+		}
 	} else
 		b->cb_buf = NULL;