summaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
authorDenys Vlasenko2021-09-09 19:26:39 +0200
committerDenys Vlasenko2021-09-30 00:15:44 +0200
commit0e0dd2149709217561d54b006c5383e087777cb4 (patch)
treedabf2bb43aeb498d8c098064beb26f3a73e92d27 /editors
parent118baea06ee83ad2f47f801e82304b442aab71f0 (diff)
downloadbusybox-0e0dd2149709217561d54b006c5383e087777cb4.zip
busybox-0e0dd2149709217561d54b006c5383e087777cb4.tar.gz
awk: never return NULL from awk_printf()
function old new delta awk_printf 651 628 -23 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'editors')
-rw-r--r--editors/awk.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/editors/awk.c b/editors/awk.c
index 6644d7d..f6314ac 100644
--- a/editors/awk.c
+++ b/editors/awk.c
@@ -2338,7 +2338,7 @@ static char *awk_printf(node *n, size_t *len)
b = NULL;
i = 0;
- while (*f) { /* "print one format spec" loop */
+ while (1) { /* "print one format spec" loop */
char *s;
char c;
char sv;
@@ -2363,7 +2363,7 @@ static char *awk_printf(node *n, size_t *len)
slen = f - s;
s = xstrndup(s, slen);
f++;
- goto tail; /* print "....%" part verbatim */
+ goto append; /* print "....%" part verbatim */
}
while (1) {
if (isalpha(c))
@@ -2412,7 +2412,7 @@ static char *awk_printf(node *n, size_t *len)
slen = strlen(s);
}
*f = sv;
-
+ append:
if (i == 0) {
b = s;
i = slen;
@@ -2422,7 +2422,7 @@ static char *awk_printf(node *n, size_t *len)
b = xrealloc(b, i + slen + 1);
strcpy(b + i, s);
i += slen;
- if (!c) /* tail? */
+ if (!c) /* s is NOT allocated and this is the last part of string? */
break;
free(s);
}