Skip to content

Commit 16b5f87

Browse files
committed
Adds negative number detection in mr2d_malloc
1 parent c00c46f commit 16b5f87

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

REDIST/SRC/pgemraux.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,12 @@ extern void Cpigemr2d();
104104
#include <stdio.h>
105105
#include <stdlib.h>
106106
#include <assert.h>
107+
const size_t NEGFLAG = -1;
107108
void *
108109
mr2d_malloc(size_t n)
109110
{
110111
void *ptr;
111-
assert(n > 0);
112+
assert((n & NEGFLAG) == 0);
112113
ptr = (void *) malloc(n);
113114
if (ptr == NULL) {
114115
fprintf(stderr, "xxmr2d:out of memory\n");

0 commit comments

Comments
 (0)