Permalink
Browse files

Ugly(!) work-around for a root leak in call_function_property.

  • Loading branch information...
1 parent d02834b commit 1cf59759a34afd60bafca5233f1d1a0e2edbaa33 @matthewd matthewd committed Sep 20, 2009
Showing with 8 additions and 5 deletions.
  1. +4 −1 ext/spidermonkey/jroot.h
  2. +4 −4 ext/spidermonkey/ruby_land_proxy.c
View
5 ext/spidermonkey/jroot.h
@@ -148,15 +148,18 @@
#define JERROR(format, args...) \
do \
{ \
- REMOVE_JROOTS; \
char _jroot_msg[_JROOT_ERRSIZE]; \
snprintf(_jroot_msg, _JROOT_ERRSIZE, (format) , ## args); \
if (_jroot_ruby) \
+ { \
+ REMOVE_JROOTS; \
rb_raise(rb_eRuntimeError, _jroot_msg); \
+ } \
else \
{ \
JSString* _jroot_err_str = JS_NewStringCopyZ(_jroot_context, _jroot_msg); \
if (_jroot_err_str) JS_SetPendingException(_jroot_context, STRING_TO_JSVAL(_jroot_err_str)); \
+ REMOVE_JROOTS; \
return JS_FALSE; \
} \
} while(0)
View
8 ext/spidermonkey/ruby_land_proxy.c
@@ -412,13 +412,13 @@ call_function_property(int argc, VALUE* argv, VALUE self)
JROOT(function);
- JSType funtype = JS_TypeOfValue(context, function);
-
// should never be anything but a function
- if (funtype != JSTYPE_FUNCTION)
+ if (!JS_ObjectIsFunction(context, function))
JERROR("Specified property \"%s\" isn't a function.", StringValueCStr(argv[0]));
- JRETURN_RUBY(call_js_function_value(proxy->runtime, proxy_value, function, argc - 1, &(argv[1])));
+ REMOVE_JROOTS;
+
+ return call_js_function_value(proxy->runtime, proxy_value, function, argc - 1, &(argv[1]));
}
/*

0 comments on commit 1cf5975

Please sign in to comment.