ext/oj/load.c in oj-2.0.5 vs ext/oj/load.c in oj-2.0.6
- old
+ new
@@ -60,11 +60,11 @@
typedef struct _ParseInfo {
char *str; /* buffer being read from */
char *s; /* current position in buffer */
CircArray circ_array;
Options options;
- void *stack_min;
+ char *stack_min;
} *ParseInfo;
static CircArray circ_array_new(void);
static void circ_array_free(CircArray ca);
static void circ_array_set(CircArray ca, VALUE obj, unsigned long id);
@@ -326,11 +326,11 @@
static VALUE
read_next(ParseInfo pi, int hint) {
VALUE obj;
- if ((void*)&obj < pi->stack_min) {
+ if ((char*)&obj < pi->stack_min) {
rb_raise(rb_eSysStackError, "JSON is too deeply nested");
}
next_non_white(pi); // skip white space
switch (*pi->s) {
case '{':
@@ -1037,15 +1037,17 @@
if (Yes == options->circular) {
pi.circ_array = circ_array_new();
}
pi.options = options;
#if IS_WINDOWS
- pi.stack_min = (void*)((char*)&obj - (512 * 1024)); // assume a 1M stack and give half to ruby
+ pi.stack_min = (char*)&obj - (512 * 1024); // assume a 1M stack and give half to ruby
#else
{
struct rlimit lim;
- if (0 == getrlimit(RLIMIT_STACK, &lim)) {
+ // When run under make on linux the limit is not reported corrected and is infinity even though
+ // the return code indicates no error. That forces the rlim_cur value as well as the return code.
+ if (0 == getrlimit(RLIMIT_STACK, &lim) && RLIM_INFINITY != lim.rlim_cur) {
pi.stack_min = (void*)((char*)&obj - (lim.rlim_cur / 4 * 3)); // let 3/4ths of the stack be used only
} else {
pi.stack_min = 0; // indicates not to check stack limit
}
}