diff --git a/myprintf.c b/myprintf.c --- a/myprintf.c +++ b/myprintf.c @@ -39,6 +39,7 @@ if ((ptr = realloc (s_str, ++size * BUF_SIZE)) == NULL) { s_str[pos] = '\0'; fputs (s_str, fp); /* print it anyway... */ + free (s_str); return EOF; } s_str = ptr; @@ -67,6 +68,7 @@ if (pos > (size * BUF_SIZE / 2)) { if ((ptr = realloc (s_str, ++size * BUF_SIZE)) == NULL) { + free (s_str); return EOF; } s_str = ptr;