Maximum image dimension should be 32767, not 32766

Presumably a glitch from when it last was lowered to "32767".
This commit is contained in:
Kim Woelders 2018-03-10 13:05:23 +01:00
parent 7dc59c88f8
commit a120e3152a
1 changed files with 6 additions and 4 deletions

View File

@ -181,12 +181,14 @@ void __imlib_SaveImage(ImlibImage * im, const char *file,
#define SET_FLAG(flags, f) ((flags) |= (f))
#define UNSET_FLAG(flags, f) ((flags) &= (~f))
/* The maximum pixmap dimension is 65535. */
/* However, for now, use 46340 (46340^2 < 2^31) to avoid buffer overflow issues. */
/* Reduced further to 32767, so that (w * h * sizeof(DATA32)) won't exceed ULONG_MAX */
/* 32767 is the maximum pixmap dimension and ensures that
* (w * h * sizeof(DATA32)) won't exceed ULONG_MAX */
#define X_MAX_DIM 32767
/* NB! The image dimensions are sometimes used in (dim << 16) like expressions
* so great care must be taken if ever it is attempted to change this
* condition */
#define IMAGE_DIMENSIONS_OK(w, h) \
( ((w) > 0) && ((h) > 0) && ((w) < X_MAX_DIM) && ((h) < X_MAX_DIM) )
( ((w) > 0) && ((h) > 0) && ((w) <= X_MAX_DIM) && ((h) <= X_MAX_DIM) )
#endif