Skip to contentSkip to conversation

prevent jump on uninitialized value

PATCH In review Sergey Senozhatsky 2 participants 2 messages Jun 27, 2012

lore
Share & tools
lore

Sergey Senozhatsky

author
#0 lore raw

PATCH 1/1 prevent jump on uninitialized value

workload is getting 'initialized' with stack garbage, so later conditional check of !workload[0] in report() is invalid.

Signed-off-by Sergey Senozhatsky <sergey.senozhatsky(a)gmail.com>

---

 src/main.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/main.cpp +1 -1
index d8e2a47..7a1b976 100644
@@ -356,7 +356,7 @@ int main(int argc, char **argv)
 	int c;
 	bool wantreport = FALSE;
 	char filename[4096];
-	char workload[4096];
+	char workload[4096] = {0,};
 	int  iterations = 1;
 
 #ifndef DISABLE_TRYCATCH
#1 lore raw

patch applied
Thanks
-C

Quoted 25 lines · Sergey Senozhatsky

workload is getting 'initialized' with stack garbage, so later conditional check of !workload[0] in report() is invalid.

Signed-off-by Sergey Senozhatsky <sergey.senozhatsky(a)gmail.com>

---

  src/main.cpp | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
src/main.cpp +1 -1
index d8e2a47..7a1b976 100644
@@ -356,7 +356,7 @@ int main(int argc, char **argv)
  	int c;
  	bool wantreport = FALSE;
  	char filename[4096];
-	char workload[4096];
+	char workload[4096] = {0,};
  	int  iterations = 1;
 
  #ifndef DISABLE_TRYCATCH