Skip to content

Commit e82dd81

Browse files
committed
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
1 parent 97eb5ef commit e82dd81

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/buffer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ char git_buf__initbuf[1];
1818
char git_buf__oom[1];
1919

2020
#define ENSURE_SIZE(b, d) \
21-
if ((d) > buf->asize && git_buf_grow(b, (d)) < 0)\
21+
if ((d) > (b)->asize && git_buf_grow((b), (d)) < 0)\
2222
return -1;
2323

2424

0 commit comments

Comments
 (0)