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