From 30bbf4dabcf2b78cc4c4b7a8bc2f1cd6dc571467 Mon Sep 17 00:00:00 2001 From: Huaqi Fang <578567190@qq.com> Date: Fri, 27 Dec 2024 15:50:03 +0800 Subject: [PATCH] target/riscv: fix close fileio and free temp when conditions are met - When `fileio` is valid, close it; - When `temp` exists, free its memory; - This ensures proper resource management. Change-Id: I66be66e3945415f2e970ea47c077942be5977541 Signed-off-by: Huaqi Fang <578567190@qq.com> --- src/target/riscv/nuclei_riscv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/target/riscv/nuclei_riscv.c b/src/target/riscv/nuclei_riscv.c index 725736d9c..aff401f11 100644 --- a/src/target/riscv/nuclei_riscv.c +++ b/src/target/riscv/nuclei_riscv.c @@ -691,9 +691,9 @@ fail: LOG_ERROR("Unexpected error happened during dumping etrace!"); retval = ERROR_OK; ok: - if (!fileio) + if (fileio) fileio_close(fileio); - if (!temp) + if (temp) free(temp); return retval;