summaryrefslogtreecommitdiff
path: root/src/buffer.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2017-06-08 11:52:32 +0200
committerPatrick Steinhardt <ps@pks.im>2017-06-08 11:58:22 +0200
commite82dd8130fa1d944b5846f5165a990b97b2590ed (patch)
tree6dc51ba91da04c871f10639c8e2b3040825bffb5 /src/buffer.c
parent97eb5ef0262bc0acf2ce66481105960b79e10ed7 (diff)
downloadlibgit2-e82dd8130fa1d944b5846f5165a990b97b2590ed.tar.gz
buffer: fix `ENSURE_SIZE` macro referencing wrong variable
While the `ENSURE_SIZE` macro gets a reference to both the buffer that is to be resized and a new size, we were not consistently referencing the passed buffer, but instead a variable `buf`, which is not passed in. Funnily enough, we never noticed because our buffers seem to always be named `buf` whenever the macro was being used. Fix the macro by always using the passed-in buffer. While at it, add braces around all mentions of passed-in variables as should be done with macros to avoid subtle errors. Found-by: Edward Thompson
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/buffer.c b/src/buffer.c
index fdb732d9e..ba8bd82d0 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -18,7 +18,7 @@ char git_buf__initbuf[1];
char git_buf__oom[1];
#define ENSURE_SIZE(b, d) \
- if ((d) > buf->asize && git_buf_grow(b, (d)) < 0)\
+ if ((d) > (b)->asize && git_buf_grow((b), (d)) < 0)\
return -1;