summaryrefslogtreecommitdiff
blob: 7e88f49058ff116c98122a5d0f2366c33db76fc6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
From 7b9ead8d480eb2be07db646e9c6383f3397beaea Mon Sep 17 00:00:00 2001
From: Jim Ramsay <lack@gentoo.org>
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