[lttng-dev] [PATCH] Fixing a dangling FILE * in config_read_session_name()

Thibault, Daniel Daniel.Thibault at drdc-rddc.gc.ca
Tue Jan 24 16:46:15 EST 2012


   In lttng-tools src/bin/lttng/conf.c's config_read_session_name(), if fscanf fails with a return value of -1, the goto error currently skips the fclose(fp).

   (My apologies for not using git patch format for my previous submission)

########################################
>From 0def6801939afbad9a43583b8708b93a04749f8b Tue, 24 Jan 2012 16:41:06 -0500
From: Daniel U. Thibault <daniel.thibault at drdc-rddc.gc.ca>
Date: Tue, 24 Jan 2012 16:40:22 -0500
Subject: [PATCH] Fixing a dangling FILE * in config_read_session_name()

diff --git a/src/bin/lttng/conf.c b/src/bin/lttng/conf.c
index 4c3b1fd..4ee6b65 100644
--- a/src/bin/lttng/conf.c
+++ b/src/bin/lttng/conf.c
@@ -190,9 +190,8 @@
 		}
 	}
 
-	fclose(fp);
-
 error:
+	if (fp != NULL) fclose(fp);
 	return NULL;
 
 found:
########################################

Daniel U. Thibault
R & D pour la défense Canada - Valcartier (RDDC Valcartier) / Defence R&D Canada - Valcartier (DRDC Valcartier)
Système de systèmes (SdS) / System of Systems (SoS)
Solutions informatiques et expérimentations (SIE) / Computing Solutions and Experimentations (CSE)
2459 Boul. Pie XI Nord
Québec, QC  G3J 1X5
CANADA
Vox : (418) 844-4000 x4245
Fax : (418) 844-4538
NAC: 918V QSDJ
Gouvernement du Canada / Government of Canada
<http://www.valcartier.drdc-rddc.gc.ca/>



More information about the lttng-dev mailing list