patch-src_misc_c 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. --- flex-2.6.4.orig/src/misc.c 2017-05-03 22:16:37.000000000 +0200
  2. +++ flex-2.6.4/src/misc.c 2019-09-30 18:07:55.823580183 +0200
  3. @@ -142,7 +142,14 @@ void add_action (const char *new_text)
  4. void *allocate_array (int size, size_t element_size)
  5. {
  6. void *mem;
  7. -#if HAVE_REALLOCARRAY
  8. +#if HAVE_REALLOCARR
  9. + mem = NULL;
  10. + if (reallocarr(&mem, (size_t) size, element_size))
  11. + flexfatal (_
  12. + ("memory allocation failed in allocate_array()"));
  13. +
  14. + return mem;
  15. +#elif HAVE_REALLOCARRAY
  16. /* reallocarray has built-in overflow detection */
  17. mem = reallocarray(NULL, (size_t) size, element_size);
  18. #else
  19. @@ -659,7 +666,12 @@ char *readable_form (int c)
  20. void *reallocate_array (void *array, int size, size_t element_size)
  21. {
  22. void *new_array;
  23. -#if HAVE_REALLOCARRAY
  24. +#if HAVE_REALLOCARR
  25. + if (reallocarr(&array, (size_t) size, element_size))
  26. + flexfatal (_("attempt to increase array size failed"));
  27. +
  28. + return array;
  29. +#elif HAVE_REALLOCARRAY
  30. /* reallocarray has built-in overflow detection */
  31. new_array = reallocarray(array, (size_t) size, element_size);
  32. #else