JS_ConvertArguments issue

View: New views
2 Messages — Rating Filter:   Alert me  

JS_ConvertArguments issue

by Anthony Catel-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

http://pastebin.com/m6f2c74f0

Line 9 is printed. How can that be possible ? Even if json_obj is not an
object JS_ConvertArguments returns JS_TRUE and leaves json_obj unchanged.

Thanks

Anthony Catel
_______________________________________________
dev-tech-js-engine mailing list
dev-tech-js-engine@...
https://lists.mozilla.org/listinfo/dev-tech-js-engine

Parent Message unknown Re: JS_ConvertArguments issue

by Blake Kaplan :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Anthony Catel <a.catel@...> wrote:
> Line 9 is printed. How can that be possible ? Even if json_obj is not an
> object JS_ConvertArguments returns JS_TRUE and leaves json_obj unchanged.

null is an object (i.e. typeof null returns "object"). It's one of those
surprising gotchas that you have to be careful of. If you don't want to allow
null, you'll have to filter it out after the JS_ConvertArguments call.
--
Blake Kaplan
_______________________________________________
dev-tech-js-engine mailing list
dev-tech-js-engine@...
https://lists.mozilla.org/listinfo/dev-tech-js-engine