From fb1804d0f4679e4e3fe4496ff7430dd8d754ee49 Mon Sep 17 00:00:00 2001 From: david parsons Date: Thu, 3 Apr 2008 11:32:19 -0700 Subject: [PATCH] Add additional ()'s in EXPAND() to make certain that we don't run wild allocating memory while building up a string. --- cstring.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cstring.h b/cstring.h index 1b561a3..78d3c8e 100644 --- a/cstring.h +++ b/cstring.h @@ -19,8 +19,8 @@ #define RESERVE(x,c) (x).text = malloc(sizeof T(x)[0] * (((x).size=0),((x).alloc=(c))) ) #define CREATE(x) RESERVE(x,100) #define EXPAND(x) ((x).size++)[((x).size < (x).alloc) \ - ? (x).text \ - : (x).text = realloc((x).text, sizeof T(x)[0] * ((x).alloc += 100))] + ? ((x).text) \ + : ((x).text = realloc((x).text, sizeof T(x)[0] * ((x).alloc += 100)))] #define DELETE(x) (x).alloc ? (free(T(x)), S(x) = (x).alloc = 0) \ : ( S(x) = 0 )