diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ipcalc.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/ipcalc.c b/src/ipcalc.c index fc81ba26..23a72207 100644 --- a/src/ipcalc.c +++ b/src/ipcalc.c @@ -306,11 +306,14 @@ int main(int argc, const char **argv) { else tmp++; } + tmp = NULL; for (; i>0; i--) { - tmp = malloc(strlen(ipStr) + 3); - sprintf(tmp,"%s.0",ipStr); - ipStr = tmp; + if (asprintf(&tmp, "%s.0", ipStr) == -1) { + fprintf(stderr, "Memory allocation failure line %d\n", __LINE__); + abort(); + } + ipStr = tmp; } } |