mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Fix a number of obvious memory leaks
Just the result of cppcheck and valgrind... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
12ca6112e5
commit
24c6197c10
5 changed files with 23 additions and 17 deletions
|
@ -1423,6 +1423,9 @@ static int copy_tree_node(GtkTreeIter *a, GtkTreeIter *b)
|
||||||
DIVE_OTU, store_dive.otu,
|
DIVE_OTU, store_dive.otu,
|
||||||
DIVE_LOCATION, store_dive.location,
|
DIVE_LOCATION, store_dive.location,
|
||||||
-1);
|
-1);
|
||||||
|
free(cylinder_text);
|
||||||
|
free(store_dive.location);
|
||||||
|
free(store_dive.suit);
|
||||||
return idx;
|
return idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1027,7 +1027,7 @@ void init_ui(int *argcp, char ***argvp)
|
||||||
if (!conf_value)
|
if (!conf_value)
|
||||||
uemis_max_dive_data = strdup("");
|
uemis_max_dive_data = strdup("");
|
||||||
else
|
else
|
||||||
uemis_max_dive_data = strdup(conf_value);
|
uemis_max_dive_data = conf_value;
|
||||||
error_info_bar = NULL;
|
error_info_bar = NULL;
|
||||||
win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||||
g_set_application_name ("subsurface");
|
g_set_application_name ("subsurface");
|
||||||
|
|
1
main.c
1
main.c
|
@ -259,6 +259,7 @@ int main(int argc, char **argv)
|
||||||
/* don't report errors - this file may not exist, but make
|
/* don't report errors - this file may not exist, but make
|
||||||
sure we remember this as the filename in use */
|
sure we remember this as the filename in use */
|
||||||
set_filename(filename, FALSE);
|
set_filename(filename, FALSE);
|
||||||
|
free((void *)filename);
|
||||||
}
|
}
|
||||||
report_dives(imported);
|
report_dives(imported);
|
||||||
if (dive_table.nr == 0)
|
if (dive_table.nr == 0)
|
||||||
|
|
|
@ -1270,6 +1270,7 @@ static void entry(const char *name, int size, const char *raw)
|
||||||
try_to_fill_dive(&cur_dive, name, buf);
|
try_to_fill_dive(&cur_dive, name, buf);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
free(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *nodename(xmlNode *node, char *buf, int len)
|
static const char *nodename(xmlNode *node, char *buf, int len)
|
||||||
|
|
|
@ -403,6 +403,7 @@ static gboolean uemis_get_answer(const char *path, char *request, int n_param_in
|
||||||
for (i = 0; i < n_param_out && j < size; i++)
|
for (i = 0; i < n_param_out && j < size; i++)
|
||||||
param_buff[i] = next_segment(buf, &j, size);
|
param_buff[i] = next_segment(buf, &j, size);
|
||||||
found_answer = TRUE;
|
found_answer = TRUE;
|
||||||
|
free(buf);
|
||||||
}
|
}
|
||||||
#if UEMIS_DEBUG
|
#if UEMIS_DEBUG
|
||||||
for (i = 0; i < n_param_out; i++)
|
for (i = 0; i < n_param_out; i++)
|
||||||
|
@ -544,9 +545,8 @@ static char *do_uemis_download(struct argument_block *args)
|
||||||
char **max_dive_data = args->max_dive_data;
|
char **max_dive_data = args->max_dive_data;
|
||||||
char **xml_buffer = args->xml_buffer;
|
char **xml_buffer = args->xml_buffer;
|
||||||
int xml_buffer_size;
|
int xml_buffer_size;
|
||||||
char *error_text = "";
|
|
||||||
char *newmax = NULL;
|
char *newmax = NULL;
|
||||||
char *deviceid;
|
char *deviceid = NULL;
|
||||||
char *result = NULL;
|
char *result = NULL;
|
||||||
char *endptr;
|
char *endptr;
|
||||||
gboolean success;
|
gboolean success;
|
||||||
|
@ -555,34 +555,33 @@ static char *do_uemis_download(struct argument_block *args)
|
||||||
uemis_info("Init Communication");
|
uemis_info("Init Communication");
|
||||||
if (! uemis_init(mountpath))
|
if (! uemis_init(mountpath))
|
||||||
return "Uemis init failed";
|
return "Uemis init failed";
|
||||||
if (! uemis_get_answer(mountpath, "getDeviceId", 0, 1, &error_text))
|
if (! uemis_get_answer(mountpath, "getDeviceId", 0, 1, &result))
|
||||||
return error_text;
|
goto bail;
|
||||||
deviceid = strdup(param_buff[0]);
|
deviceid = strdup(param_buff[0]);
|
||||||
/* the answer from the DeviceId call becomes the input parameter for getDeviceData */
|
/* the answer from the DeviceId call becomes the input parameter for getDeviceData */
|
||||||
if (! uemis_get_answer(mountpath, "getDeviceData", 1, 0, &error_text))
|
if (! uemis_get_answer(mountpath, "getDeviceData", 1, 0, &result))
|
||||||
return error_text;
|
goto bail;
|
||||||
/* param_buff[0] is still valid */
|
/* param_buff[0] is still valid */
|
||||||
if (! uemis_get_answer(mountpath, "initSession", 1, 6, &error_text))
|
if (! uemis_get_answer(mountpath, "initSession", 1, 6, &result))
|
||||||
return error_text;
|
goto bail;
|
||||||
uemis_info("Start download");
|
uemis_info("Start download");
|
||||||
if (! uemis_get_answer(mountpath, "processSync", 0, 2, &error_text))
|
if (! uemis_get_answer(mountpath, "processSync", 0, 2, &result))
|
||||||
return error_text;
|
goto bail;
|
||||||
param_buff[1] = "notempty";
|
param_buff[1] = "notempty";
|
||||||
newmax = get_divenr(*max_dive_data, deviceid);
|
newmax = get_divenr(*max_dive_data, deviceid);
|
||||||
for (;;) {
|
for (;;) {
|
||||||
param_buff[2] = newmax;
|
param_buff[2] = newmax;
|
||||||
param_buff[3] = 0;
|
param_buff[3] = 0;
|
||||||
success = uemis_get_answer(mountpath, "getDivelogs", 3, 0, &error_text);
|
success = uemis_get_answer(mountpath, "getDivelogs", 3, 0, &result);
|
||||||
/* process the buffer we have assembled */
|
/* process the buffer we have assembled */
|
||||||
if (mbuf) {
|
if (mbuf) {
|
||||||
char *next_seg = process_raw_buffer(mbuf, &newmax);
|
char *next_seg = process_raw_buffer(mbuf, &newmax);
|
||||||
buffer_add(xml_buffer, &xml_buffer_size, next_seg);
|
buffer_add(xml_buffer, &xml_buffer_size, next_seg);
|
||||||
|
free(next_seg);
|
||||||
}
|
}
|
||||||
/* if we got an error, deal with it */
|
/* if we got an error, deal with it */
|
||||||
if (!success) {
|
if (!success)
|
||||||
result = error_text;
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
/* also, if we got nothing back, we should stop trying */
|
/* also, if we got nothing back, we should stop trying */
|
||||||
if (!param_buff[3])
|
if (!param_buff[3])
|
||||||
break;
|
break;
|
||||||
|
@ -598,8 +597,8 @@ static char *do_uemis_download(struct argument_block *args)
|
||||||
}
|
}
|
||||||
*args->max_dive_data = update_max_dive_data(*max_dive_data, deviceid, newmax);
|
*args->max_dive_data = update_max_dive_data(*max_dive_data, deviceid, newmax);
|
||||||
free(newmax);
|
free(newmax);
|
||||||
if (! uemis_get_answer(mountpath, "terminateSync", 0, 3, &error_text))
|
if (! uemis_get_answer(mountpath, "terminateSync", 0, 3, &result))
|
||||||
return error_text;
|
goto bail;
|
||||||
if (! strcmp(param_buff[0], "error")) {
|
if (! strcmp(param_buff[0], "error")) {
|
||||||
if (! strcmp(param_buff[2],"Out of Memory"))
|
if (! strcmp(param_buff[2],"Out of Memory"))
|
||||||
result = ERR_FS_FULL;
|
result = ERR_FS_FULL;
|
||||||
|
@ -610,6 +609,8 @@ static char *do_uemis_download(struct argument_block *args)
|
||||||
#if UEMIS_DEBUG > 5
|
#if UEMIS_DEBUG > 5
|
||||||
fprintf(debugfile, "XML buffer \"%s\"", *xml_buffer);
|
fprintf(debugfile, "XML buffer \"%s\"", *xml_buffer);
|
||||||
#endif
|
#endif
|
||||||
|
bail:
|
||||||
|
free(deviceid);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue