Skip to contentSkip to conversation

diff --no-index: don't leak buffers in queue_diff

PATCH New Bobby Powers 1 participant 1 message Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 diff --no-index: don't leak buffers in queue_diff

queue_diff uses two strbufs, and at the end of the function strbuf_reset was called. This only reset the length of the buffer - any allocated memory was leaked. Using strbuf_release fixes this.

---
 diff-no-index.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff-no-index.c +2 -2
index 3080b66..f0b0010 100644
@@ -123,8 +123,8 @@ static int queue_diff(struct diff_options *o,
 		}
 		string_list_clear(&p1, 0);
 		string_list_clear(&p2, 0);
-		strbuf_reset(&buffer1);
-		strbuf_reset(&buffer2);
+		strbuf_release(&buffer1);
+		strbuf_release(&buffer2);
 
 		return ret;
 	} else {
Signature · 1 line
1.7.10.2.521.g8ddb639