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

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