summaryrefslogtreecommitdiffstats
path: root/core/uemis-downloader.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2019-10-27 06:54:10 -0400
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-10-27 07:35:46 -0700
commitee6b89268ea5ba83796238514cf3e4ea58460638 (patch)
tree205de0560b331f4df783709dac9c647eff220fd2 /core/uemis-downloader.c
parent86b76b0aff528fd6eab54303b8f9c23f9b18ea53 (diff)
downloadsubsurface-ee6b89268ea5ba83796238514cf3e4ea58460638.tar.gz
Cleanup: close open file before returning
This prevents a resource leak. Found by Coverity. Fixes CID 350080 The commit also includes some tiny whitespace/empty line fixes. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core/uemis-downloader.c')
-rw-r--r--core/uemis-downloader.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/core/uemis-downloader.c b/core/uemis-downloader.c
index 3d5119968..180115271 100644
--- a/core/uemis-downloader.c
+++ b/core/uemis-downloader.c
@@ -105,10 +105,10 @@ static void add_to_divespot_mapping(int divespot_id, struct dive_site *ds)
struct divespot_mapping *ndm = (struct divespot_mapping*)calloc(1, sizeof(struct divespot_mapping));
struct divespot_mapping **pdm = &divespot_mapping;
struct divespot_mapping *cdm = *pdm;
-
+
while (cdm && cdm->next)
cdm = cdm->next;
-
+
ndm->divespot_id = divespot_id;
ndm->dive_site = ds;
ndm->next = NULL;
@@ -605,6 +605,7 @@ static bool uemis_get_answer(const char *path, char *request, int n_param_in,
}
if (read(ans_file, tmp, 100) < 0) {
free(ans_path);
+ close(ans_file);
return false;
}
close(ans_file);
@@ -1183,7 +1184,7 @@ static bool load_uemis_divespot(const char *mountpath, int divespot_id)
static void get_uemis_divespot(device_data_t *devdata, const char *mountpath, int divespot_id, struct dive *dive)
{
struct dive_site *nds = dive->dive_site;
-
+
if (is_divespot_mappable(divespot_id)) {
struct dive_site *ds = get_dive_site_by_divespot_id(divespot_id);
unregister_dive_from_dive_site(dive);