diff options
| author | Shlomi Fish <shlomif@shlomifish.org> | 2017-01-04 13:07:40 +0000 |
|---|---|---|
| committer | Shlomi Fish <shlomif@shlomifish.org> | 2017-01-04 13:07:40 +0000 |
| commit | 9edd91ed1cb11932718f5150c17347696af4fc70 (patch) | |
| tree | aa79fa34c5ae4c7906f4d05d6a87d688f1b2d00a /src | |
| parent | Extract some common code into a routine. (diff) | |
| parent | Fix misplaced parenthesis reported by compiler warning. (diff) | |
| download | inkscape-9edd91ed1cb11932718f5150c17347696af4fc70.tar.gz inkscape-9edd91ed1cb11932718f5150c17347696af4fc70.zip | |
Merged.
(bzr r15369.1.9)
Diffstat (limited to 'src')
| -rw-r--r-- | src/libuemf/uemf.h | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/libuemf/uemf.h b/src/libuemf/uemf.h index 82fd0990c..05566af06 100644 --- a/src/libuemf/uemf.h +++ b/src/libuemf/uemf.h @@ -168,12 +168,24 @@ extern "C" { #define U_ROUND(A) ( (A) > 0 ? floor((A)+0.5) : ( (A) < 0 ? -floor(-(A)+0.5) : (A) ) ) #define MAKE_MIN_PTR(A,B) ( A < B ? A : B) -/* This is tricky. The next one can be called with a size which is either an int or an unsigned int. - The former can be negative, which is obviously wrong, but testing for that means that the size cannot - be more than INT_MAX/2. Accept that limitation since no reasonable EMF record or file should ever be that large. - B must be an INT or size_t. - If a uint16_t is used gcc complains about the first test. Force B to be at least as big as int (at run time) */ -#define IS_MEM_UNSAFE(A,B,C) ( (sizeof(B) < sizeof(int) || (int)(B)) < 0 ? 1 : ((int8_t *)(A) > (int8_t *)(C) ? 1 : ((int8_t *)(C) - (int8_t *)(A) >= (int)(B) ? 0 : 1 ))) //!< Return 1 when a region of memory starting at A of B bytes extends beyond pointer C + +/* IS_MEM_UNSAFE takes 3 parameters: + A start address of a block of allocated memory + B offset into this block starting at A + C address of final byte of a block of allocated memory. + Returns + 1 if B cannot be an int or size_t + 1 if C > A + 1 if A+B is not in the range A to C, inclusive + 0 otherwise. + B may be an int, an unsigned int, or a size_t. An int can be negative, + which is obviously wrong, but testing for that means that the size + of B cannot be more than INT_MAX/2. Accept that limitation since + no reasonable EMF record or file should ever be that large. + If B is a uint16_t gcc complains about the first test. + This Macro must not be used where B needs more than 32 bits! +*/ +#define IS_MEM_UNSAFE(A,B,C) ( (sizeof(B) < sizeof(int) || (int)(B) < 0) ? 1 : ((int8_t *)(A) > (int8_t *)(C) ? 1 : ((int8_t *)(C) - (int8_t *)(A) >= (int)(B) ? 0 : 1 ))) /** @} */ |
