Add range checking for NUM2USHRT macro, per SF Bug #675353.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@4387 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
691cb91056
commit
212275f45d
1 changed files with 6 additions and 1 deletions
|
|
@ -4,7 +4,12 @@
|
|||
|
||||
#include "ruby.h"
|
||||
|
||||
#define NUM2USHRT(n) (unsigned short) NUM2UINT(n)
|
||||
#define NUM2USHRT(n) (\
|
||||
(0 <= NUM2UINT(n) && NUM2UINT(n) <= USHRT_MAX)\
|
||||
? (unsigned short) NUM2UINT(n) \
|
||||
: (rb_raise(rb_eArgError, "integer %d out of range of `unsigned short'",\
|
||||
NUM2UINT(n)), (short)0)\
|
||||
)
|
||||
|
||||
#define NUM2SHRT(n) (\
|
||||
(SHRT_MIN <= NUM2INT(n) && NUM2INT(n) <= SHRT_MAX)\
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue