From 70ba651d66bfbae037acda8069428454b528f093 Mon Sep 17 00:00:00 2001 From: "Alan T. DeKok" Date: Mon, 9 Mar 2015 09:57:58 -0400 Subject: [PATCH] Realloc string to the correct length --- src/main/parser.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/parser.c b/src/main/parser.c index 53a1ee6ecf9e..3e19b6198f72 100644 --- a/src/main/parser.c +++ b/src/main/parser.c @@ -193,7 +193,16 @@ static ssize_t condition_tokenize_string(TALLOC_CTX *ctx, char **out, char cons *out = talloc_steal(ctx, data.ptr); data.strvalue = NULL; } else { - *q = '\0'; /* terminate the output string */ + char *out2; + + *(q++) = '\0'; /* terminate the output string */ + + out2 = talloc_realloc(ctx, *out, char, (q - *out)); + if (!out2) { + *error = "Out of memory"; + return -1; + } + *out = out2; } p++;