summaryrefslogtreecommitdiff
path: root/graphics/xpm/patches/patch-ae
blob: a94b683aaabba99ba886419ea07ad89c2f1b85c3 (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
$NetBSD: patch-ae,v 1.1 2004/09/16 15:09:01 minskim Exp $

--- lib/Attrib.c.orig	Thu Mar 19 13:50:59 1998
+++ 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,11 +46,14 @@ 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) {