From 12a999769d2a76f14e740f5c5f280551586623e7 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Tue, 3 Jun 2008 14:08:21 +0200 Subject: [PATCH] Fix empty input fields in SWAT; [#5515]. --- source/web/swat.c | 16 ++++++++++------ 1 files changed, 10 insertions(+), 6 deletions(-) diff --git a/source/web/swat.c b/source/web/swat.c index 6d8f4ca..49c2da1 100644 --- a/source/web/swat.c +++ b/source/web/swat.c @@ -86,28 +86,32 @@ static const char *fix_quotes(TALLOC_CTX *ctx, const char *str) /* Count the number of quotes. */ newstring_len = 1; - while (*str) { - if ( *str == '\"') { + + p = (char *) str; + + while (*p) { + if (*p == '\"') { newstring_len += quote_len; } else { newstring_len++; } - ++str; + ++p; } newstring = TALLOC_ARRAY(ctx, char, newstring_len); - if (!newstring) { + if (newstring == NULL) { return ""; } + for (p = newstring; *str; str++) { - if ( *str == '\"') { + if (*str == '\"') { strncpy( p, """, quote_len); p += quote_len; } else { *p++ = *str; } - ++str; } *p = '\0'; + return newstring; } -- 1.5.4.5