summaryrefslogtreecommitdiff
path: root/src/buffer.c
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2014-09-10 19:50:29 +0200
committerVicent Marti <tanoku@gmail.com>2014-09-10 19:58:22 +0200
commit8c028e1a88c2d2aac4a4086202568bee43678aa8 (patch)
tree78fc80b00a62a259419b59d54c3b34e8dcdf334b /src/buffer.c
parent7c2a062cdf9c0514cdf32f4f8bd07cf52d183c8b (diff)
Do not create references with empty names
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/buffer.c b/src/buffer.c
index cdf8ca0..7c2b86b 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -215,11 +215,12 @@ unsigned char *strbuf_detach(strbuf *buf)
{
unsigned char *data = buf->ptr;
- if (buf->asize == 0 || buf->ptr == strbuf__oom)
- return NULL;
+ if (buf->asize == 0 || buf->ptr == strbuf__oom) {
+ /* return an empty string */
+ return calloc(1, 1);
+ }
strbuf_init(buf, 0);
-
return data;
}