[hackers] [sbase] printf: no need to nul-terminate after strndup || Hiltjo Posthuma

From: <git_AT_suckless.org>
Date: Sat, 28 Mar 2015 22:03:52 +0100 (CET)

commit c5a51123b1450a63379dfe19fc35c0a4394132b7
Author: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
Date: Fri Mar 27 12:21:13 2015 +0100

    printf: no need to nul-terminate after strndup

diff --git a/printf.c b/printf.c
index 770b7cb..13ba21e 100644
--- a/printf.c
+++ b/printf.c
_AT_@ -62,7 +62,6 @@ main(int argc, char *argv[])
                         for (; strchr("+-0123456789", format[i]); i++);
                         if (j != i) {
                                 tmp = estrndup(format + j, i - j);
- tmp[i - j] = 0;
                                 width = estrtonum(tmp, 0, INT_MAX);
                                 free(tmp);
                         } else {
_AT_@ -84,7 +83,6 @@ main(int argc, char *argv[])
                                 for (; strchr("+-0123456789", format[i]); i++);
                                 if (j != i) {
                                         tmp = estrndup(format + j, i - j);
- tmp[i - j] = 0;
                                         precision = estrtonum(tmp, 0, INT_MAX);
                                         free(tmp);
                                 } else {
Received on Sat Mar 28 2015 - 22:03:52 CET

This archive was generated by hypermail 2.3.0 : Sat Mar 28 2015 - 22:12:17 CET