summaryrefslogtreecommitdiff
blob: 1e94602e0e5e0974f32a4c67ba1dc281e755acc9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
--- a/Source/FreeImage/PluginXPM.cpp
+++ b/Source/FreeImage/PluginXPM.cpp
@@ -181,6 +181,11 @@
 		}
 		free(str);
 
+		// check info string
+		if((width <= 0) || (height <= 0) || (colors <= 0) || (cpp <= 0)) {
+			throw "Improperly formed info string";
+		}
+
         if (colors > 256) {
 			dib = FreeImage_AllocateHeader(header_only, width, height, 24, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK);
 		} else {
@@ -193,7 +198,7 @@
 			FILE_RGBA rgba;
 
 			str = ReadString(io, handle);
-			if(!str)
+			if(!str || (strlen(str) < cpp))
 				throw "Error reading color strings";
 
 			std::string chrs(str,cpp); //create a string for the color chars using the first cpp chars