From 1fe97ae089cd6161b96dd53dca975888a1f8dcc4 Mon Sep 17 00:00:00 2001 From: Pekka Lampila Date: Mon, 28 Jul 2008 16:44:20 +0300 Subject: [PATCH] Don't crash when native constructor is called with an invalid type Added SWFDEC_FIXME for those cases, because now we will ignore the call, but that is not the correct thing to do --- swfdec/swfdec_as_context.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/swfdec/swfdec_as_context.c b/swfdec/swfdec_as_context.c index 24b25c69..7d0f7f25 100644 --- a/swfdec/swfdec_as_context.c +++ b/swfdec/swfdec_as_context.c @@ -840,7 +840,9 @@ start: SwfdecAsValue rval = { 0, }; if (frame->argc >= native->min_args && (native->type == 0 || - g_type_is_a (G_OBJECT_TYPE (frame->thisp), native->type))) { + g_type_is_a (G_OBJECT_TYPE (frame->thisp), native->type)) && + (!frame->construct || native->construct_type == 0 || + g_type_is_a (G_OBJECT_TYPE (frame->thisp), native->construct_type))) { SwfdecAsValue *argv; /* accumulate argv */ if (frame->argc == 0 || frame->argv != NULL) { @@ -871,6 +873,11 @@ start: argv, &rval); if (argv != frame->argv) g_free (argv); + } else { + if (frame->construct && native->construct_type != 0 && + !g_type_is_a (G_OBJECT_TYPE (frame->thisp), native->construct_type)) { + SWFDEC_FIXME ("Ignoring call to native constructor with invalid type"); + } } swfdec_as_frame_return (frame, &rval); goto start; -- 2.11.4.GIT