2
1

0001-Add-missing-limits.h-include-for-UINT_MAX.patch 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. From ebce9f1b129ebc8f2b17afa02a4ffcb9453c11d9 Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Rapha=C3=ABl=20M=C3=A9lotte?= <raphael.melotte@mind.be>
  3. Date: Mon, 24 Apr 2023 17:27:35 +0200
  4. Subject: [PATCH] Add missing limits.h include for UINT_MAX
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. encode-basic.c uses 'UINT_MAX', which is available in the 'limits.h'
  9. header.
  10. In some configurations that build with zlib from [1], by chance
  11. limits.h gets indirectly included when including 'z-imp.h' (the
  12. includes are: 'z-imp.h' -> 'zlib.h' -> 'zconf.h' -> 'limits.h'), so
  13. the build succeeds.
  14. When using other zlib implementations however (for example from [2]),
  15. limits.h is not necessarily included indirectly, which leads to the
  16. build failing in the following way:
  17. source/fitz/encode-basic.c: In function 'deflate_write':
  18. source/fitz/encode-basic.c:343:27: error: 'UINT_MAX' undeclared (first use in this function)
  19. 343 | newbufsize = n >= UINT_MAX ? UINT_MAX : deflateBound(&state->z, n);
  20. | ^~~~~~~~
  21. source/fitz/encode-basic.c:26:1: note: 'UINT_MAX' is defined in header '<limits.h>'; did you forget to '#include <limits.h>'?
  22. Add the missing include, so that the build succeeds no matter if zlib
  23. indirectly includes 'limit.h' or not.
  24. Similarly, also add it in output-ps.c where it's also missing.
  25. [1]: https://zlib.net/
  26. [2]: https://github.com/zlib-ng/zlib-ng
  27. Signed-off-by: Raphaël Mélotte <raphael.melotte@mind.be>
  28. Upstream: https://bugs.ghostscript.com/show_bug.cgi?id=706667
  29. ---
  30. source/fitz/encode-basic.c | 2 ++
  31. source/fitz/output-ps.c | 2 ++
  32. 2 files changed, 4 insertions(+)
  33. diff --git a/source/fitz/encode-basic.c b/source/fitz/encode-basic.c
  34. index 03a4ff76b..84f0c35e6 100644
  35. --- a/source/fitz/encode-basic.c
  36. +++ b/source/fitz/encode-basic.c
  37. @@ -24,6 +24,8 @@
  38. #include "z-imp.h"
  39. +#include <limits.h>
  40. +
  41. struct ahx
  42. {
  43. fz_output *chain;
  44. diff --git a/source/fitz/output-ps.c b/source/fitz/output-ps.c
  45. index ef22c3cd6..3dc8ea17d 100644
  46. --- a/source/fitz/output-ps.c
  47. +++ b/source/fitz/output-ps.c
  48. @@ -24,6 +24,8 @@
  49. #include "z-imp.h"
  50. +#include <limits.h>
  51. +
  52. typedef struct ps_band_writer_s
  53. {
  54. fz_band_writer super;
  55. --
  56. 2.39.1