summaryrefslogtreecommitdiff
path: root/meta-openbmc-mods/meta-common/recipes-devtools/mtd-util/files/0002-Add-fix-for-possible-freeing-of-mismatched-memory.patch
blob: 1c5bc5843eecb5b9274427582d029ce8cf5b9895 (plain)
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
From 5606cfc0857dc6fe1071c14f6906d866048f6c18 Mon Sep 17 00:00:00 2001
From: AkshayRav <akshay.raveendran.k@intel.com>
Date: Thu, 28 Apr 2022 13:57:32 +0530
Subject: [PATCH] Add fix for possible freeing of mismatched memory (#8)

* Add fix for possible freeing of mismatched memory

Memory referenced by "buf" was allocated through function
"new[]" and released through function "delete". The fix changes the
release function to "delete[]" to remove the possible freeing of
mismatched memory.

Signed-off-by: AKSHAY RAVEENDRAN K <akshay.raveendran.k@intel.com>
---
 mtd-util.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mtd-util.cpp b/mtd-util.cpp
index 7f2f98d..d6136f0 100644
--- a/mtd-util.cpp
+++ b/mtd-util.cpp
@@ -391,7 +391,7 @@ int main(int argc, char* argv[])
             {
                 std::cerr << "failed to parse '" << argv[optind]
                           << "' as integer" << std::endl;
-                delete buf;
+                delete[] buf;
                 return 1;
             }
             optind++;
@@ -473,7 +473,7 @@ int main(int argc, char* argv[])
                 break;
             case ACTION_WRITE_TO_FLASH:
                 ret = buf_to_flash(dev, buf, start, len);
-                delete buf;
+                delete[] buf;
                 break;
 #endif /* DEVELOPER_OPTIONS */
             case ACTION_CP_TO_FILE: