Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 629dfe2

Browse files
committed
Merged revisions 76740 via svnmerge from
svn+ssh://[email protected]/python/trunk ........ r76740 | mark.dickinson | 2009-12-10 10:36:32 +0000 (Thu, 10 Dec 2009) | 8 lines Replace the size check for PyMem_MALLOC and PyMem_REALLOC with an almost equivalent[*] check that doesn't produce compiler warnings about a 'x < 0' check on an unsigned type. [*] it's equivalent for inputs of type size_t or Py_ssize_t, or any smaller unsigned or signed integer type. ........
1 parent 3f9afd8 commit 629dfe2

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

Include/pymem.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ PyAPI_FUNC(void) PyMem_Free(void *);
7171
pymalloc. To solve these problems, allocate an extra byte. */
7272
/* Returns NULL to indicate error if a negative size or size larger than
7373
Py_ssize_t can represent is supplied. Helps prevents security holes. */
74-
#define PyMem_MALLOC(n) (((n) < 0 || (n) > PY_SSIZE_T_MAX) ? NULL \
74+
#define PyMem_MALLOC(n) ((size_t)(n) > (size_t)PY_SSIZE_T_MAX ? NULL \
7575
: malloc((n) ? (n) : 1))
76-
#define PyMem_REALLOC(p, n) (((n) < 0 || (n) > PY_SSIZE_T_MAX) ? NULL \
76+
#define PyMem_REALLOC(p, n) ((size_t)(n) > (size_t)PY_SSIZE_T_MAX ? NULL \
7777
: realloc((p), (n) ? (n) : 1))
7878
#define PyMem_FREE free
7979

0 commit comments

Comments
 (0)