commit 573165850a9a9cd479bc6af922b3b73a7717a459
parent 2d7323b8b74bdad6119b99d75909757e6deb30e4
Author: phoebos <ben@bvnf.space>
Date: Sat, 1 Oct 2022 21:52:39 +0100
pwd: another missing free
Diffstat:
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/pwd.c b/pwd.c
@@ -50,11 +50,13 @@ flag_P:
char *buf = NULL;
for (char *tmp = NULL; tmp == NULL; size += 32) {
- buf = realloc(buf, size);
- if (buf == NULL) {
+ char *b = realloc(buf, size);
+ if (b == NULL) {
+ free(buf);
perror("pwd");
return 1;
}
+ buf = b;
errno = 0;
tmp = getcwd(buf, size);