Fix realpath(3) memory leak 96/270496/1 accepted/tizen_7.0_unified accepted/tizen_7.0_unified_hotfix tizen_7.0 tizen_7.0_hotfix accepted/tizen/7.0/unified/20221110.060611 accepted/tizen/7.0/unified/hotfix/20221116.105659 accepted/tizen/unified/20220204.132338 accepted/tizen/unified/20220220.211421 submit/tizen/20220203.172140 submit/tizen/20220219.164033 tizen_7.0_m2_release
authorKarol Lewandowski <k.lewandowsk@samsung.com>
Thu, 3 Feb 2022 11:40:06 +0000 (12:40 +0100)
committerKarol Lewandowski <k.lewandowsk@samsung.com>
Thu, 3 Feb 2022 11:40:06 +0000 (12:40 +0100)
Change-Id: Ic2e2264a8dab194884decfa5acb9035ea712b149

src/bugreport-service/diagnostics/diagnostics.c

index f038cad..71df306 100644 (file)
@@ -103,17 +103,21 @@ static bool is_report_file(const char *path, const char *reports_dir)
 
        if (access(r_path, F_OK) == -1) {
                _E("access() for %s error: %m\n", path);
-               return false;
+               goto out_err;
        }
 
        char *start = strstr(r_path, reports_dir);
 
        if (start == NULL) {
                _I("%s is not within %s\n", r_path, reports_dir);
-               return false;
+               goto out_err;
        }
 
        return true;
+
+out_err:
+       free(r_path);
+       return false;
 }
 
 static enum diagnostics_type check_report_type(const char *path)