1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
From 7bfa66d3cd6bf2199b1a5b60330f548e087ba9d0 Mon Sep 17 00:00:00 2001
From: Nobuhiro Iwamatsu <iwamatsu@debian.org>
Date: Mon, 8 Aug 2022 17:35:42 +0900
Subject: [PATCH 9/9] Fix cpp check for double free
Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@debian.org>
---
.../core/pcie/emulation/cpu_em/generic_pcie_hal2/shim.cxx | 8 ++++----
.../core/pcie/emulation/hw_em/generic_pcie_hal2/shim.cxx | 8 ++++----
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/runtime_src/core/pcie/emulation/cpu_em/generic_pcie_hal2/shim.cxx b/src/runtime_src/core/pcie/emulation/cpu_em/generic_pcie_hal2/shim.cxx
index aee22b4e1..ebde9b150 100644
--- a/src/runtime_src/core/pcie/emulation/cpu_em/generic_pcie_hal2/shim.cxx
+++ b/src/runtime_src/core/pcie/emulation/cpu_em/generic_pcie_hal2/shim.cxx
@@ -120,10 +120,10 @@ namespace xclcpuemhal2 {
}
if (buf_size < new_size)
{
- void *temp = buf;
- buf = (void*) realloc(temp,new_size);
- if (!buf) // prevent leak of original buf
- free(temp);
+ void *temp, *temp1 = buf;
+ temp = (void*) realloc(temp1,new_size);
+ if (!temp) // prevent leak of original buf
+ free(buf);
return new_size;
}
return buf_size;
diff --git a/src/runtime_src/core/pcie/emulation/hw_em/generic_pcie_hal2/shim.cxx b/src/runtime_src/core/pcie/emulation/hw_em/generic_pcie_hal2/shim.cxx
index d0754bf1b..10332ada6 100755
--- a/src/runtime_src/core/pcie/emulation/hw_em/generic_pcie_hal2/shim.cxx
+++ b/src/runtime_src/core/pcie/emulation/hw_em/generic_pcie_hal2/shim.cxx
@@ -171,10 +171,10 @@ namespace xclhwemhal2 {
}
if (buf_size < new_size)
{
- void *temp = buf;
- buf = (void*) realloc(temp,new_size);
- if (!buf) // prevent leak of original buf
- free(temp);
+ void *temp, *temp1 = buf;
+ temp = (void*) realloc(temp1,new_size);
+ if (!temp) // prevent leak of original buf
+ free(buf);
return new_size;
}
return buf_size;
--
2.36.1
|