diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2021-09-09 19:26:39 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2021-09-30 00:15:44 +0200 |
commit | 0e0dd2149709217561d54b006c5383e087777cb4 (patch) | |
tree | dabf2bb43aeb498d8c098064beb26f3a73e92d27 | |
parent | 118baea06ee83ad2f47f801e82304b442aab71f0 (diff) | |
download | busybox-w32-0e0dd2149709217561d54b006c5383e087777cb4.tar.gz busybox-w32-0e0dd2149709217561d54b006c5383e087777cb4.tar.bz2 busybox-w32-0e0dd2149709217561d54b006c5383e087777cb4.zip |
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>
-rw-r--r-- | editors/awk.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/editors/awk.c b/editors/awk.c index 6644d7d6f..f6314ac72 100644 --- a/editors/awk.c +++ b/editors/awk.c | |||
@@ -2338,7 +2338,7 @@ static char *awk_printf(node *n, size_t *len) | |||
2338 | 2338 | ||
2339 | b = NULL; | 2339 | b = NULL; |
2340 | i = 0; | 2340 | i = 0; |
2341 | while (*f) { /* "print one format spec" loop */ | 2341 | while (1) { /* "print one format spec" loop */ |
2342 | char *s; | 2342 | char *s; |
2343 | char c; | 2343 | char c; |
2344 | char sv; | 2344 | char sv; |
@@ -2363,7 +2363,7 @@ static char *awk_printf(node *n, size_t *len) | |||
2363 | slen = f - s; | 2363 | slen = f - s; |
2364 | s = xstrndup(s, slen); | 2364 | s = xstrndup(s, slen); |
2365 | f++; | 2365 | f++; |
2366 | goto tail; /* print "....%" part verbatim */ | 2366 | goto append; /* print "....%" part verbatim */ |
2367 | } | 2367 | } |
2368 | while (1) { | 2368 | while (1) { |
2369 | if (isalpha(c)) | 2369 | if (isalpha(c)) |
@@ -2412,7 +2412,7 @@ static char *awk_printf(node *n, size_t *len) | |||
2412 | slen = strlen(s); | 2412 | slen = strlen(s); |
2413 | } | 2413 | } |
2414 | *f = sv; | 2414 | *f = sv; |
2415 | 2415 | append: | |
2416 | if (i == 0) { | 2416 | if (i == 0) { |
2417 | b = s; | 2417 | b = s; |
2418 | i = slen; | 2418 | i = slen; |
@@ -2422,7 +2422,7 @@ static char *awk_printf(node *n, size_t *len) | |||
2422 | b = xrealloc(b, i + slen + 1); | 2422 | b = xrealloc(b, i + slen + 1); |
2423 | strcpy(b + i, s); | 2423 | strcpy(b + i, s); |
2424 | i += slen; | 2424 | i += slen; |
2425 | if (!c) /* tail? */ | 2425 | if (!c) /* s is NOT allocated and this is the last part of string? */ |
2426 | break; | 2426 | break; |
2427 | free(s); | 2427 | free(s); |
2428 | } | 2428 | } |