leak: fixed for some leaks [1/1]
PD#SWPL-24422
Problem:
fd leak
mem leak
Solution:
close the file opened
free the priv struct
Verify:
Patchbuild
Change-Id: I02a543c4ec7749c88379b2eed27c610108618bab
Signed-off-by: Zhiqiang Han <zhiqiang.han@amlogic.com>
diff --git a/src/segment.c b/src/segment.c
index 74ca633..85db6a5 100644
--- a/src/segment.c
+++ b/src/segment.c
@@ -141,6 +141,14 @@
if (p_ctx->ts_fd == -1 || !p_ctx->index_fp || !p_ctx->dat_fp) {
DVR_DEBUG(1, "%s open file failed [%s, %s, %s], reason:%s", __func__,
ts_fname, index_fname, dat_fname, strerror(errno));
+ if (p_ctx->ts_fd != -1)
+ close(p_ctx->ts_fd);
+ if (p_ctx->index_fp)
+ fclose(p_ctx->index_fp);
+ if (p_ctx->dat_fp)
+ fclose(p_ctx->dat_fp);
+ if (p_ctx->ongoing_fp)
+ fclose(p_ctx->ongoing_fp);
free(p_ctx);
*p_handle = NULL;
return DVR_FAILURE;