summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarol Lewandowski <k.lewandowsk@samsung.com>2021-06-11 12:20:40 +0200
committerKarol Lewandowski <k.lewandowsk@samsung.com>2021-06-11 12:22:50 +0200
commit9fe0d45ec2406c49a343bbd81040e68ef62e39b8 (patch)
treec7e47a824f5eac4f9c67884560ec8d694a8619e9
parentea9eb8858ba7c4da58bc97e90965233bbd01e95b (diff)
downloadcrash-worker-9fe0d45ec2406c49a343bbd81040e68ef62e39b8.tar.gz
crash-worker-9fe0d45ec2406c49a343bbd81040e68ef62e39b8.tar.bz2
crash-worker-9fe0d45ec2406c49a343bbd81040e68ef62e39b8.zip
bugreport-service: fix memory leak
Change-Id: I8609072ca5a0eaf55c613390ece3d58b891e6d51
-rw-r--r--src/bugreport-service/diagnostics/diagnostics.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/bugreport-service/diagnostics/diagnostics.c b/src/bugreport-service/diagnostics/diagnostics.c
index f20b357..f038cad 100644
--- a/src/bugreport-service/diagnostics/diagnostics.c
+++ b/src/bugreport-service/diagnostics/diagnostics.c
@@ -308,7 +308,7 @@ static int share_file(const char *path)
{
assert(path);
- const char *dest_file = get_temp_file_name();
+ char *dest_file = get_temp_file_name();
if (dest_file == NULL)
return -BR_ERR_INTERNAL;
@@ -317,15 +317,19 @@ static int share_file(const char *path)
if (copy_file(dest_file, path) == -1) {
_E("copy_file() error");
+ free(dest_file);
return -BR_ERR_INTERNAL;
}
int fd = open(dest_file, O_RDONLY);
if (fd == -1) {
_E("open() file: \"%s\" error: %m\n", path);
+ free(dest_file);
return -BR_ERR_INTERNAL;
}
+
unlink(dest_file);
+ free(dest_file);
return fd;
}