summaryrefslogtreecommitdiff
path: root/dev-util/kdbg/files/kdbg-3.0.1-fix-rare-memleak.patch
blob: 44a2b33623f49e519269e436dd1cf9b6ad583e5b (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
From 0feb0986f220126177084badf67813ccdbaa996c Mon Sep 17 00:00:00 2001
From: Daniels Umanovskis <daniels@umanovskis.se>
Date: Fri, 13 Mar 2020 13:48:19 +0100
Subject: [PATCH] Fix a rare memory leak in the register display window

---
 kdbg/regwnd.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kdbg/regwnd.cpp b/kdbg/regwnd.cpp
index edb0e55..93008f9 100644
--- a/kdbg/regwnd.cpp
+++ b/kdbg/regwnd.cpp
@@ -274,11 +274,12 @@ static char* toRaw(const QString& hex, uint& length)
     static bool littleendian=(*testChar==1);
 
     length=((hex.length()-2)%2)+((hex.length()-2)/2);
+    if (hex.length()<=2) return 0;
+
     char* data=new char[length];
 
     if (littleendian) {
 	uint j=0;
-	if (hex.length()<=2) return 0;
 	for (int i=hex.length()-1; i>=2; ) {
 	    if (j%2==0)
 		data[j/2]=hexCharToDigit(hex[i].toLatin1());
@@ -288,7 +289,6 @@ static char* toRaw(const QString& hex, uint& length)
 	}
     } else { // big endian
 	uint j=0;
-	if (hex.length()<=2) return 0;
 	for (int i=2; i<hex.length(); ) {
 	    if (j%2==0)
 		data[j/2]=hexCharToDigit(hex[i].toLatin1())<<4;