Skip to content

Instantly share code, notes, and snippets.

@paulblei
Created March 30, 2018 01:49
Show Gist options
  • Save paulblei/9755aacbab8aefe7b1fd0072694d7d86 to your computer and use it in GitHub Desktop.
Save paulblei/9755aacbab8aefe7b1fd0072694d7d86 to your computer and use it in GitHub Desktop.
unsigned long ruby_strtoul(const char *str, char **endptr, int base);
#define STRTOUL(str, endptr, base) (ruby_strtoul((str), (endptr), (base)))
// ....
static VALUE
pack_pack(int argc, VALUE *argv, VALUE ary)
{
// ...
long len, idx, plen;
// ....
else if (ISDIGIT(*p)) {
errno = 0;
len = STRTOUL(p, (char**)&p, 10);
if (errno) {
rb_raise(rb_eRangeError, "pack length too big");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment