Branch: Tag:

1999-05-12

1999-05-12 04:40:08 by Fredrik Hübinette (Hubbe) <hubbe@hubbe.net>

patch for malloc(0) returning 0

Rev: src/builtin_functions.c:1.170

5:   \*/   /**/   #include "global.h" - RCSID("$Id: builtin_functions.c,v 1.169 1999/05/11 18:56:32 mirar Exp $"); + RCSID("$Id: builtin_functions.c,v 1.170 1999/05/12 04:40:08 hubbe Exp $");   #include "interpret.h"   #include "svalue.h"   #include "pike_macros.h"
2614:    ONERROR tmp;    ONERROR tmp2;    +  if(!a->size) +  return allocate_array(0); +     stack = malloc(sizeof(int)*a->size);    links = malloc(sizeof(int)*a->size);   
2906:    struct diff_magic_link **stack;    char *marks;    +  if(!cmptbl->size) +  return allocate_array(0); +     stack = malloc(sizeof(struct diff_magic_link*)*cmptbl->size);       if (!stack) {
2918:    /* NB: marks is used for optimization purposes only */    marks = calloc(blen, 1);    -  if (!marks) { +  if (!marks && blen) {    int args = 0;    free(stack);    SIMPLE_OUT_OF_MEMORY_ERROR("diff_longest_sequence", blen);