about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--cache.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/cache.c b/cache.c
index 57c8918..b169d20 100644
--- a/cache.c
+++ b/cache.c
@@ -215,19 +215,25 @@ static int fill_slot(struct cache_slot *slot)
 		return errno;
 
 	/* Redirect stdout to lockfile */
-	if (dup2(slot->lock_fd, STDOUT_FILENO) == -1)
+	if (dup2(slot->lock_fd, STDOUT_FILENO) == -1) {
+		close(tmp);
 		return errno;
+	}
 
 	/* Generate cache content */
 	slot->fn();
 
 	/* update stat info */
-	if (fstat(slot->lock_fd, &slot->cache_st))
+	if (fstat(slot->lock_fd, &slot->cache_st)) {
+		close(tmp);
 		return errno;
+	}
 
 	/* Restore stdout */
-	if (dup2(tmp, STDOUT_FILENO) == -1)
+	if (dup2(tmp, STDOUT_FILENO) == -1) {
+		close(tmp);
 		return errno;
+	}
 
 	/* Close the temporary filedescriptor */
 	if (close(tmp))
catgirl/commit/chat.c?h=1.3&id=1daf23d8a5261d42bf64e75b44cb943086cedcf8&follow=1'>Use a wide pad for the topicJune McEnroe 2018-08-03Ignore NOTICEs not sent to the channelJune McEnroe 2018-08-03Handle KICK and NICKJune McEnroe 2018-08-03Continue on EINTR from pollJune McEnroe 2018-08-03Handle ACTIONsJune McEnroe 2018-08-03Use more octal char literalsJune McEnroe 2018-08-03Send a WHO in response to NAMES to get usernamesJune McEnroe 2018-08-03Colorize nicks and channelsJune McEnroe 2018-08-03Add support for mIRC colorsJune McEnroe 2018-08-03Handle bold, italic, underlineJune McEnroe 2018-08-03Add prift function for "prefix shift"June McEnroe 2018-08-03Link with -lcurseswJune McEnroe 2018-08-02Use libtls "compat" ciphersJune McEnroe 2018-08-02Add UI and handle some kinds of server messagesJune McEnroe 2018-08-02Add chroot.tar targetJune McEnroe