From 7b9ead8d480eb2be07db646e9c6383f3397beaea Mon Sep 17 00:00:00 2001 From: Jim Ramsay Date: Thu, 6 Aug 2009 12:22:26 -0400 Subject: [PATCH] Fixed segfault if Weather or Clouds not present Though the variables 'weatherFound' and 'cloudsFound' were being set properly by fscanf, their values were never actually checked. Furthermore, the strings (Weather, Clouds, tmp1 and tmp2) were not being initialized to NULL as the code seems to have been expecting. --- Src/wmFrog.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Src/wmFrog.c b/Src/wmFrog.c index e2d82af..af4101a 100644 --- a/Src/wmFrog.c +++ b/Src/wmFrog.c @@ -68,10 +68,10 @@ int n, s, m, i, dt1, dt2, dt3 ; XEvent event; char command[1024], Line[512], FileName[10]; FILE *fp; - char* Weather; - char* Clouds; - char* tmp1; - char* tmp2; + char* Weather = NULL; + char* Clouds = NULL; + char* tmp1 = NULL; + char* tmp2 = NULL; int intensity=0; char* precip; char* desc; @@ -238,7 +238,7 @@ FILE *fp; keepgoing=1; { - do{ + if (weatherFound) do{ tmp1=mystrsep(&Weather,";"); @@ -289,7 +289,7 @@ FILE *fp; while(keepgoing); } - do{ + if (cloudsFound) do{ tmp1=mystrsep(&Clouds,";"); if(tmp1) { -- 1.6.3.3