Blame SOURCES/0055-code-clean-up.patch

121cca
From 353866cf8f9d2fff89d226598c97dfd33229fe35 Mon Sep 17 00:00:00 2001
121cca
From: Lyonel Vincent <lyonel@ezix.org>
121cca
Date: Tue, 12 Oct 2021 16:28:35 +0200
121cca
Subject: [PATCH 55/65] code clean-up
121cca
121cca
be more prudent before freeing memory
121cca
---
121cca
 src/core/usb.cc | 4 ++++
121cca
 1 file changed, 4 insertions(+)
121cca
121cca
diff --git a/src/core/usb.cc b/src/core/usb.cc
121cca
index da65e10..7074d87 100644
121cca
--- a/src/core/usb.cc
121cca
+++ b/src/core/usb.cc
121cca
@@ -311,6 +311,7 @@ static bool load_usbids(const string & name)
121cca
         buffer[linelen-1] = '\0';                 // chop \n
121cca
       string line = string(buffer);
121cca
       free(buffer);
121cca
+      buffer = NULL;
121cca
 
121cca
       description = NULL;
121cca
       t = 0;
121cca
@@ -338,6 +339,7 @@ static bool load_usbids(const string & name)
121cca
         }
121cca
       }
121cca
     }
121cca
+    if(buffer != NULL) free(buffer);
121cca
   }
121cca
 
121cca
   fclose(usbids);
121cca
@@ -393,6 +395,7 @@ bool scan_usb(hwNode & n)
121cca
     {
121cca
       string line = hw::strip(string(buffer));
121cca
       free(buffer);
121cca
+      buffer = NULL;
121cca
 
121cca
       if(line.length()<=0)
121cca
       {
121cca
@@ -497,6 +500,7 @@ bool scan_usb(hwNode & n)
121cca
         }
121cca
       }
121cca
     }
121cca
+    if(buffer != NULL) free(buffer);
121cca
   }
121cca
   if(defined)
121cca
     addUSBChild(n, device, bus, lev, prnt);
121cca
-- 
121cca
2.33.1
121cca