Michael Gilbert <michael.s.gilb...@gmail.com> writes:
> poppler.

Ah indeed they have a slightly modified version:

inline static void *gmallocn(int nObjs, int objSize, bool checkoverflow)
{
  int n;

  if (nObjs == 0) {
    return NULL;
  }
  n = nObjs * objSize;
  if (objSize <= 0 || nObjs < 0 || nObjs >= INT_MAX / objSize) {
    fprintf(stderr, "Bogus memory allocation size\n");
    if (checkoverflow) return NULL;
    else exit(1);
  }
  return gmalloc(n, checkoverflow);
}

Wouldn't it be better to write this as

inline static void *gmallocn(int nObjs, int objSize, bool checkoverflow)
{
  int n;

  if (nObjs == 0) {
    return NULL;
  }
  n = nObjs * objSize;
  if (objSize <= 0 || nObjs < 0 || nObjs >= INT_MAX / objSize) {
    if (checkoverflow) {
      return NULL;
    } else {
      fprintf(stderr, "Bogus memory allocation size\n");
      exit(1);
    }
  }
  return gmalloc(n, checkoverflow);
}

if it is not an error when checkoverflow is set?

-Timo



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to