summaryrefslogtreecommitdiffstats
path: root/gd-sa4.patch
blob: 50d33d0c5b1dd7ff83bd6619ca3f3c2d480f4101 (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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
The following issue has been found by Coverity static analysis tool.

Error: FORWARD_NULL (CWE-476): [#def5]
gd-2.0.35/gd_topal.c:1790: assign_zero: Assigning: "cquantize" = "NULL".
gd-2.0.35/gd_topal.c:1798: cond_false: Condition "cimP", taking false branch
gd-2.0.35/gd_topal.c:1804: else_branch: Reached else branch
gd-2.0.35/gd_topal.c:1807: cond_false: Condition "!oim->trueColor", taking false branch
gd-2.0.35/gd_topal.c:1815: if_end: End of if statement
gd-2.0.35/gd_topal.c:1819: cond_true: Condition "oim->transparent >= 0", taking true branch
gd-2.0.35/gd_topal.c:1823: cond_true: Condition "colorsWanted > maxColors", taking true branch
gd-2.0.35/gd_topal.c:1827: cond_true: Condition "!cimP", taking true branch
gd-2.0.35/gd_topal.c:1829: cond_false: Condition "!nim->pixels", taking false branch
gd-2.0.35/gd_topal.c:1833: if_end: End of if statement
gd-2.0.35/gd_topal.c:1834: cond_true: Condition "i < nim->sy", taking true branch
gd-2.0.35/gd_topal.c:1837: cond_true: Condition "!nim->pixels[i]", taking true branch
gd-2.0.35/gd_topal.c:1839: goto: Jumping to label "outOfMemory"
gd-2.0.35/gd_topal.c:2027: label: Reached label "outOfMemory"
gd-2.0.35/gd_topal.c:2028: cond_true: Condition "oim->trueColor", taking true branch
gd-2.0.35/gd_topal.c:2030: cond_true: Condition "!cimP", taking true branch
gd-2.0.35/gd_topal.c:2032: cond_true: Condition "i < nim->sy", taking true branch
gd-2.0.35/gd_topal.c:2034: cond_true: Condition "nim->pixels[i]", taking true branch
gd-2.0.35/gd_topal.c:2038: loop: Jumping back to the beginning of the loop
gd-2.0.35/gd_topal.c:2032: loop_begin: Jumped back to beginning of loop
gd-2.0.35/gd_topal.c:2032: cond_true: Condition "i < nim->sy", taking true branch
gd-2.0.35/gd_topal.c:2034: cond_true: Condition "nim->pixels[i]", taking true branch
gd-2.0.35/gd_topal.c:2038: loop: Jumping back to the beginning of the loop
gd-2.0.35/gd_topal.c:2032: loop_begin: Jumped back to beginning of loop
gd-2.0.35/gd_topal.c:2032: cond_false: Condition "i < nim->sy", taking false branch
gd-2.0.35/gd_topal.c:2038: loop_end: Reached end of loop
gd-2.0.35/gd_topal.c:2039: cond_true: Condition "nim->pixels", taking true branch
gd-2.0.35/gd_topal.c:2044: if_fallthrough: Falling through to end of if statement
gd-2.0.35/gd_topal.c:2047: if_end: End of if statement
gd-2.0.35/gd_topal.c:2050: cond_true: Condition "i < (32 /* 1 << 5 */)", taking true branch
gd-2.0.35/gd_topal.c:2052: var_deref_op: Dereferencing null pointer "cquantize".

Error: FORWARD_NULL (CWE-476): [#def6]
gd-2.0.35/gd_topal.c:1798: cond_true: Condition "cimP", taking true branch
gd-2.0.35/gd_topal.c:1801: cond_false: Condition "!nim", taking false branch
gd-2.0.35/gd_topal.c:1803: if_end: End of if statement
gd-2.0.35/gd_topal.c:1804: if_fallthrough: Falling through to end of if statement
gd-2.0.35/gd_topal.c:1806: if_end: End of if statement
gd-2.0.35/gd_topal.c:1807: cond_false: Condition "!oim->trueColor", taking false branch
gd-2.0.35/gd_topal.c:1815: if_end: End of if statement
gd-2.0.35/gd_topal.c:1819: cond_true: Condition "oim->transparent >= 0", taking true branch
gd-2.0.35/gd_topal.c:1823: cond_true: Condition "colorsWanted > maxColors", taking true branch
gd-2.0.35/gd_topal.c:1827: cond_false: Condition "!cimP", taking false branch
gd-2.0.35/gd_topal.c:1842: if_end: End of if statement
gd-2.0.35/gd_topal.c:1857: cond_true: Condition "!cquantize", taking true branch
gd-2.0.35/gd_topal.c:1857: var_compare_op: Comparing "cquantize" to null implies that "cquantize" might be null.
gd-2.0.35/gd_topal.c:1860: goto: Jumping to label "outOfMemory"
gd-2.0.35/gd_topal.c:2027: label: Reached label "outOfMemory"
gd-2.0.35/gd_topal.c:2028: cond_true: Condition "oim->trueColor", taking true branch
gd-2.0.35/gd_topal.c:2030: cond_false: Condition "!cimP", taking false branch
gd-2.0.35/gd_topal.c:2044: else_branch: Reached else branch
gd-2.0.35/gd_topal.c:2050: cond_true: Condition "i < (32 /* 1 << 5 */)", taking true branch
gd-2.0.35/gd_topal.c:2052: var_deref_op: Dereferencing null pointer "cquantize".

Error: FORWARD_NULL (CWE-476): [#def7]
gd-2.0.35/gd_topal.c:1798: cond_false: Condition "cimP", taking false branch
gd-2.0.35/gd_topal.c:1804: else_branch: Reached else branch
gd-2.0.35/gd_topal.c:1807: cond_false: Condition "!oim->trueColor", taking false branch
gd-2.0.35/gd_topal.c:1815: if_end: End of if statement
gd-2.0.35/gd_topal.c:1819: cond_true: Condition "oim->transparent >= 0", taking true branch
gd-2.0.35/gd_topal.c:1823: cond_true: Condition "colorsWanted > maxColors", taking true branch
gd-2.0.35/gd_topal.c:1827: cond_true: Condition "!cimP", taking true branch
gd-2.0.35/gd_topal.c:1829: cond_true: Condition "!nim->pixels", taking true branch
gd-2.0.35/gd_topal.c:1829: var_compare_op: Comparing "nim->pixels" to null implies that "nim->pixels" might be null.
gd-2.0.35/gd_topal.c:1832: goto: Jumping to label "outOfMemory"
gd-2.0.35/gd_topal.c:2027: label: Reached label "outOfMemory"
gd-2.0.35/gd_topal.c:2028: cond_true: Condition "oim->trueColor", taking true branch
gd-2.0.35/gd_topal.c:2030: cond_true: Condition "!cimP", taking true branch
gd-2.0.35/gd_topal.c:2032: cond_true: Condition "i < nim->sy", taking true branch
gd-2.0.35/gd_topal.c:2034: var_deref_op: Dereferencing null pointer "nim->pixels".


diff -up gd-2.0.35/gd_topal.c.sa4 gd-2.0.35/gd_topal.c
--- gd-2.0.35/gd_topal.c.sa4	2012-12-10 13:30:19.666363149 +0100
+++ gd-2.0.35/gd_topal.c	2012-12-10 13:37:50.550729535 +0100
@@ -2029,15 +2029,15 @@ outOfMemory:
     {
       if (!cimP) {
         /* On failure only */
-        for (i = 0; i < nim->sy; i++)
-  	{
-  	  if (nim->pixels[i])
-  	    {
-  	      gdFree (nim->pixels[i]);
-  	    }
-  	}
         if (nim->pixels)
   	{
+          for (i = 0; i < nim->sy; i++)
+  	  {
+  	    if (nim->pixels[i])
+  	      {
+  	        gdFree (nim->pixels[i]);
+  	      }
+  	  }
   	  gdFree (nim->pixels);
   	}
         nim->pixels = 0;
@@ -2047,27 +2047,27 @@ outOfMemory:
       }
     }
 success:
-  for (i = 0; i < HIST_C0_ELEMS; i++)
-    {
-      if (cquantize->histogram[i])
-	{
-	  gdFree (cquantize->histogram[i]);
-	}
-    }
-  if (cquantize->histogram)
-    {
-      gdFree (cquantize->histogram);
-    }
-  if (cquantize->fserrors)
-    {
-      gdFree (cquantize->fserrors);
-    }
-  if (cquantize->error_limiter_storage)
-    {
-      gdFree (cquantize->error_limiter_storage);
-    }
   if (cquantize)
     {
+      for (i = 0; i < HIST_C0_ELEMS; i++)
+        {
+          if (cquantize->histogram[i])
+	    {
+	      gdFree (cquantize->histogram[i]);
+	    }
+        }
+      if (cquantize->histogram)
+        {
+          gdFree (cquantize->histogram);
+        }
+      if (cquantize->fserrors)
+        {
+          gdFree (cquantize->fserrors);
+        }
+      if (cquantize->error_limiter_storage)
+        {
+          gdFree (cquantize->error_limiter_storage);
+        }
       gdFree (cquantize);
     }