Skip to content

Instantly share code, notes, and snippets.

@kyprizel
Created December 11, 2012 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kyprizel/4258758 to your computer and use it in GitHub Desktop.
Save kyprizel/4258758 to your computer and use it in GitHub Desktop.
Leak fix
From 22e62551e81082d83e04ac7d18262f283b2d695e Mon Sep 17 00:00:00 2001
From: Eldar Zaitov <eldar@kyprizel.net>
Date: Tue, 11 Dec 2012 17:52:09 +0400
Subject: [PATCH] fixed fd leak in logger
---
engine/core.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/engine/core.c b/engine/core.c
index bbc0c22..5bca9ef 100644
--- a/engine/core.c
+++ b/engine/core.c
@@ -673,6 +673,17 @@ static void logger_api_vlogmsg(ib_provider_inst_t *lpi,
*/
iface->logger(lpi_data->fp, level, ib, file, line, which_fmt, ap);
+ if (lpi_data->fp != NULL) {
+ if (fclose(lpi_data->fp) < 0) {
+ fprintf(stderr,
+ "logger_api_vlogmsg:Failed closing our fp %p: %s\n",
+ (void *)lpi_data->fp, strerror(errno));
+
+ }
+ lpi_data->fp = NULL;
+ lpi_data->log_uri = NULL;
+ }
+
done:
if (new_fmt) {
free(new_fmt);
--
1.7.10.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment