[Dnsmasq-discuss] [PATCH] remove self assignment on variable creatrion on stack

Donald Sharp donaldsharp72 at gmail.com
Mon Mar 2 21:45:46 GMT 2020


In C when declaring a variable on the stack, it is assigned
what ever happens to be on the stack at the place the variable
is accessed in memory from previous usage.  Let's explicitly call out a
value instead of using whatever happens to be on the stack
at the point of creation of the sav value.

Signed-off-by: Donald Sharp <donaldsharp72 at gmail.com>
---
 src/util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/util.c b/src/util.c
index f058c92..02aa76b 100644
--- a/src/util.c
+++ b/src/util.c
@@ -560,7 +560,7 @@ int parse_hex(char *in, unsigned char *out, int maxlen,
 		  int j, bytes = (1 + (r - in))/2;
 		  for (j = 0; j < bytes; j++)
 		    { 
-		      char sav = sav;
+		      char sav = 0;
 		      if (j < bytes - 1)
 			{
 			  sav = in[(j+1)*2];
-- 
2.25.0




More information about the Dnsmasq-discuss mailing list