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

--- lib/hashtab.c.orig	Thu Mar 19 13:51:00 1998
+++ lib/hashtab.c
@@ -135,7 +135,7 @@ HashTableGrows(table)
     xpmHashTable *table;
 {
     xpmHashAtom *atomTable = table->atomTable;
-    int size = table->size;
+    unsigned int size = table->size;
     xpmHashAtom *t, *p;
     int i;
     int oldSize = size;
@@ -144,6 +144,8 @@ HashTableGrows(table)
     HASH_TABLE_GROWS
 	table->size = size;
     table->limit = size / 3;
+    if (size >= SIZE_MAX / sizeof(*atomTable)) 
+	return (XpmNoMemory);
     atomTable = (xpmHashAtom *) XpmMalloc(size * sizeof(*atomTable));
     if (!atomTable)
 	return (XpmNoMemory);
@@ -204,6 +206,8 @@ xpmHashTableInit(table)
     table->size = INITIAL_HASH_SIZE;
     table->limit = table->size / 3;
     table->used = 0;
+    if (table->size >= SIZE_MAX / sizeof(*atomTable))
+	return (XpmNoMemory);
     atomTable = (xpmHashAtom *) XpmMalloc(table->size * sizeof(*atomTable));
     if (!atomTable)
 	return (XpmNoMemory);