summaryrefslogtreecommitdiff
path: root/x11/XFree86-libs/patches/patch-ao
blob: 2a6e740dcaab81971f524ac949c7aa463ab9e64b (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
$NetBSD: patch-ao,v 1.3 2004/09/16 19:28:56 minskim Exp $

--- extras/Xpm/lib/Attrib.c.orig	1999-01-11 07:23:09.000000000 -0600
+++ extras/Xpm/lib/Attrib.c
@@ -35,7 +35,7 @@
 #include "XpmI.h"
 
 /* 3.2 backward compatibility code */
-LFUNC(CreateOldColorTable, int, (XpmColor *ct, int ncolors,
+LFUNC(CreateOldColorTable, int, (XpmColor *ct, unsigned int ncolors,
 				 XpmColor ***oldct));
 
 LFUNC(FreeOldColorTable, void, (XpmColor **colorTable, int ncolors));
@@ -46,12 +46,15 @@ LFUNC(FreeOldColorTable, void, (XpmColor
 static int
 CreateOldColorTable(ct, ncolors, oldct)
     XpmColor *ct;
-    int ncolors;
+    unsigned int ncolors;
     XpmColor ***oldct;
 {
     XpmColor **colorTable, **color;
     int a;
 
+    if (ncolors >= SIZE_MAX / sizeof(XpmColor *))
+	return XpmNoMemory;
+
     colorTable = (XpmColor **) XpmMalloc(ncolors * sizeof(XpmColor *));
     if (!colorTable) {
 	*oldct = NULL;