summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristos Zoulas <christos@zoulas.com>2023-04-02 16:33:37 +0000
committerChristos Zoulas <christos@zoulas.com>2023-04-02 16:33:37 +0000
commitc8bba134ac1f3c9f5b052486a7694c5b48e498bc (patch)
tree95d51e68bbbcddfd47be5a85fce28c34e52c435a
parent9337839b47ef5e7d8af943e2287e5aaac3040a21 (diff)
downloadfile-git-c8bba134ac1f3c9f5b052486a7694c5b48e498bc.tar.gz
Also reset ebuf for consistency.
-rw-r--r--src/buffer.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/buffer.c b/src/buffer.c
index fbdb2222..9e5a5c8f 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -27,7 +27,7 @@
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: buffer.c,v 1.11 2023/04/02 16:31:54 christos Exp $")
+FILE_RCSID("@(#)$File: buffer.c,v 1.12 2023/04/02 16:33:37 christos Exp $")
#endif /* lint */
#include "magic.h"
@@ -71,8 +71,11 @@ buffer_fill(const struct buffer *bb)
b->elen = CAST(size_t, b->st.st_size) < b->flen ?
CAST(size_t, b->st.st_size) : b->flen;
- if (b->elen == 0)
+ if (b->elen == 0) {
+ free(b->ebuf);
+ b->ebuf = NULL;
return 0;
+ }
if ((b->ebuf = malloc(b->elen)) == NULL)
goto out;