[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Gnash-commit] /srv/bzr/gnash/avm2 r9685: Fix segfault caused by nul
From: |
strk |
Subject: |
Re: [Gnash-commit] /srv/bzr/gnash/avm2 r9685: Fix segfault caused by null objects in the scope stack. |
Date: |
Sun, 16 Nov 2008 18:15:04 +0100 |
On Sat, Nov 15, 2008 at 09:16:39PM +0800, Tom Stellard wrote:
> So, what I should be doing is something like:
>
> prop =getProperty();
> if(!prop)
> log_aserror();
>
> pushStack(prop);
>
> and if I try to pass a NULL value to pushStack, it should abort. What
> is the preferred way to abort? Should I throw an exception?
I usually use an assertion, like:
pushStack(as_object* o) { assert(o); ... }
So you can drop the additional check at compile time
when you're pretty sure there's no caller passing NULL.
Recently I also started using a PARANOIA_LEVEL macro, like in:
#if PARANOIA_LEVEL > 1
assert(o);
#endif
As for the as_error, wrap it always in IF_VERBOSE_ASCODING_ERRORS
so any error can also be disabled at compile time.
Still, you don't want to abort if user passes a NULL property,
so you'd do something like:
prop = getProperty();
if ( !prop )
{
IF_VERBOSE_ASCODING_ERRORS(
log_aserror(_("..."), ...);
);
return;
}
pushStack(prop);
--strk;