From 06cd783a8994b704c066aa59e11a6e76292d806e Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Thu, 18 Dec 2014 21:26:14 +0200 Subject: More removal of extra unused byte. --- helpers/testdfa.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'helpers/testdfa.c') diff --git a/helpers/testdfa.c b/helpers/testdfa.c index 25a229a2..092a13d8 100644 --- a/helpers/testdfa.c +++ b/helpers/testdfa.c @@ -392,14 +392,14 @@ setup_pattern(const char *pattern, size_t *len) * from that. */ if (buf == NULL) { - buf = (char *) malloc(*len + 2); + buf = (char *) malloc(*len + 1); if (buf == NULL) { fprintf(stderr, "%s: malloc failed\n", __func__); exit(EXIT_FAILURE); } buflen = *len; } else if (*len > buflen) { - buf = (char *) realloc(buf, *len + 2); + buf = (char *) realloc(buf, *len + 1); if (buf == NULL) { fprintf(stderr, "%s: realloc failed\n", __func__); exit(EXIT_FAILURE); -- cgit v1.2.3 From 24ddf2742b0034089bce38e5f4ebd99b93c6e161 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Thu, 9 Apr 2015 18:04:18 +0300 Subject: Further fixes from Andrew Schorr. --- helpers/testdfa.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) (limited to 'helpers/testdfa.c') diff --git a/helpers/testdfa.c b/helpers/testdfa.c index 092a13d8..2b773467 100644 --- a/helpers/testdfa.c +++ b/helpers/testdfa.c @@ -372,10 +372,10 @@ setup_pattern(const char *pattern, size_t *len) { size_t is_multibyte = 0; int c, c2; - size_t buflen = 0; + size_t buflen; mbstate_t mbs; bool has_anchor = false; - char *buf = NULL; + char *buf; char *dest; const char *src, *end; @@ -391,21 +391,12 @@ setup_pattern(const char *pattern, size_t *len) * escaped characters translated, and generate the regex * from that. */ + buf = (char *) malloc(*len + 1); if (buf == NULL) { - buf = (char *) malloc(*len + 1); - if (buf == NULL) { - fprintf(stderr, "%s: malloc failed\n", __func__); - exit(EXIT_FAILURE); - } - buflen = *len; - } else if (*len > buflen) { - buf = (char *) realloc(buf, *len + 1); - if (buf == NULL) { - fprintf(stderr, "%s: realloc failed\n", __func__); - exit(EXIT_FAILURE); - } - buflen = *len; + fprintf(stderr, "%s: malloc failed\n", __func__); + exit(EXIT_FAILURE); } + buflen = *len; dest = buf; while (src < end) { -- cgit v1.2.3