[PATCH 1/2] Cochran: Fixed late declaration/initialization of rbstream

John Van Ostrand john at vanostrand.com
Fri Jul 14 16:50:56 PDT 2017


An error could cause code to jump past initialiation resulting
in freeing an undefined variable.
---
 src/cochran_commander.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/cochran_commander.c b/src/cochran_commander.c
index 5020792..a21478d 100644
--- a/src/cochran_commander.c
+++ b/src/cochran_commander.c
@@ -834,6 +834,7 @@ cochran_commander_device_foreach (dc_device_t *abstract, dc_dive_callback_t call
 
 	cochran_data_t data;
 	data.logbook = NULL;
+	dc_rbstream_t *rbstream = NULL;
 
 	// Often used variables
 	unsigned int rb_logbook_entry_count = layout->rb_logbook_entry_count;
@@ -933,7 +934,6 @@ cochran_commander_device_foreach (dc_device_t *abstract, dc_dive_callback_t call
 
 	// Create rbstream
 	unsigned int last_start_address = array_uint32_le( data.logbook + ((head_dive - 1) * layout->rb_logbook_entry_size) + layout->pt_profile_end );
-	dc_rbstream_t *rbstream = NULL;
 	rc = dc_rbstream_new (&rbstream, abstract, 1, 131072, layout->rb_profile_begin, layout->rb_profile_end, last_start_address );
 
 	int invalid_profile_flag = 0;
-- 
2.4.11



More information about the devel mailing list