44f5b8c
From 93686f8ba8c1ed6bf559dbfda53f9c7d702c76b5 Mon Sep 17 00:00:00 2001
44f5b8c
From: Lubomir Rintel <lkundrak@v3.sk>
44f5b8c
Date: Thu, 21 Jul 2016 18:13:58 +0200
44f5b8c
Subject: [PATCH] usb_modeswitch: don't return a value from stack
44f5b8c
44f5b8c
The memory is not allocated anymore when the function returns and that
44f5b8c
causes no end of mayhem and undefined behavior.
44f5b8c
44f5b8c
Let's make it static so that it's perserved after the return. It wastes
44f5b8c
LINE_DIM bytes of memory and requires the caller to consume the value
44f5b8c
before another call, but that's no problem.
44f5b8c
44f5b8c
http://www.draisberghof.de/usb_modeswitch/bb/viewtopic.php?f=2&t=2557
44f5b8c
---
44f5b8c
 usb_modeswitch.c | 3 ++-
44f5b8c
 1 file changed, 2 insertions(+), 1 deletion(-)
44f5b8c
44f5b8c
diff --git a/usb_modeswitch.c b/usb_modeswitch.c
44f5b8c
index f9c8b2e..3373ccf 100644
44f5b8c
--- a/usb_modeswitch.c
44f5b8c
+++ b/usb_modeswitch.c
44f5b8c
@@ -1855,7 +1855,8 @@ char* ReadParseParam(const char* FileName, char *VariableName)
44f5b8c
 	char *FirstQuote, *LastQuote, *P1, *P2;
44f5b8c
 	int Line=0;
44f5b8c
 	unsigned Len=0, Pos=0;
44f5b8c
-	char Str[LINE_DIM], *token, *configPos;
44f5b8c
+	static char Str[LINE_DIM];
44f5b8c
+	char *token, *configPos;
44f5b8c
 	FILE *file = NULL;
44f5b8c
 
44f5b8c
 	// Reading and storing input during the first call
44f5b8c
-- 
44f5b8c
2.7.4
44f5b8c