commit a78522637bcc7d3f4120a37fff0673e1bec74430 from: Stefan Sperling date: Thu Nov 30 14:37:45 2017 UTC handle fdopen() failure in opentemp() commit - cb74ff2103a31757b3dca49acc797f9bdca13335 commit + a78522637bcc7d3f4120a37fff0673e1bec74430 blob - cc11a64952e9b6b57d63beb873439def9a735840 blob + fdc0c136e4d89280f9ef8bb0f43d937624cf58e0 --- lib/diff.c +++ lib/diff.c @@ -35,6 +35,7 @@ opentemp(void) { char name[PATH_MAX]; int fd; + FILE *f; if (strlcpy(name, "/tmp/got.XXXXXXXX", sizeof(name)) >= sizeof(name)) return NULL; @@ -44,7 +45,13 @@ opentemp(void) return NULL; unlink(name); - return (fdopen(fd, "w+")); + f = fdopen(fd, "w+"); + if (f == NULL) { + close(fd); + return NULL; + } + + return f; } const struct got_error *