|
Lines 11-16
Link Here
|
| 11 |
#include <stdlib.h> |
11 |
#include <stdlib.h> |
| 12 |
#include <stddef.h> |
12 |
#include <stddef.h> |
| 13 |
#include <string.h> |
13 |
#include <string.h> |
|
|
14 |
#include <limits.h> |
| 14 |
#include "gmem.h" |
15 |
#include "gmem.h" |
| 15 |
|
16 |
|
| 16 |
#ifdef DEBUG_MEM |
17 |
#ifdef DEBUG_MEM |
|
Lines 141-147
void *gmallocn(int nObjs, int objSize) {
Link Here
|
| 141 |
int n; |
142 |
int n; |
| 142 |
|
143 |
|
| 143 |
n = nObjs * objSize; |
144 |
n = nObjs * objSize; |
| 144 |
if (objSize == 0 || n / objSize != nObjs) { |
145 |
if (objSize <= 0 || nObjs < 0 || nObjs >= INT_MAX / objSize) { |
| 145 |
fprintf(stderr, "Bogus memory allocation size\n"); |
146 |
fprintf(stderr, "Bogus memory allocation size\n"); |
| 146 |
exit(1); |
147 |
exit(1); |
| 147 |
} |
148 |
} |
|
Lines 152-158
void *greallocn(void *p, int nObjs, int
Link Here
|
| 152 |
int n; |
153 |
int n; |
| 153 |
|
154 |
|
| 154 |
n = nObjs * objSize; |
155 |
n = nObjs * objSize; |
| 155 |
if (objSize == 0 || n / objSize != nObjs) { |
156 |
if (objSize <= 0 || nObjs < 0 || nObjs >= INT_MAX / objSize) { |
| 156 |
fprintf(stderr, "Bogus memory allocation size\n"); |
157 |
fprintf(stderr, "Bogus memory allocation size\n"); |
| 157 |
exit(1); |
158 |
exit(1); |
| 158 |
} |
159 |
} |