diff --git a/c-programming/asprintf.c b/c-programming/asprintf.c index 4d5dee6..4dbdda5 100644 --- a/c-programming/asprintf.c +++ b/c-programming/asprintf.c @@ -17,13 +17,13 @@ ssize_t asprintf(char** strp, char* format, ...) { return -1; } - *strp = malloc(size + 1); + *strp = malloc(++size); if (*strp == NULL) { va_end(args); return -1; } - ssize_t result = (ssize_t) vsnprintf(*strp, size + 1, format, args); + ssize_t result = (ssize_t) vsnprintf(*strp, size, format, args); va_end(args); if (result < 0) {