crashes in AUBase::RestoreState
crashes in AUBase::RestoreState
- Subject: crashes in AUBase::RestoreState
- From: Marc Poirier <email@hidden>
- Date: Fri, 7 Feb 2003 17:56:24 +0100 (CET)
Hi. I was just playing with an AU host app that is supporting importing
VST plugin settings to AU counterparts with the "vstdata" dictionary key,
etc. I found that the process was crashing in AUBase::RestoreState
because the host was not creating all of the standard AU Dictionary keys
and AUBase::RestoreState does not fetch dictionary values in a safe
fashion: a fatal combination. For example, I'd like to direct the class'
attention to the first part of AUBase::RestoreState (with added commentary
from me):
CFNumberRef cfnum = reinterpret_cast<CFNumberRef>(CFDictionaryGetValue(dict, kVersionString));
/* if kVersionString is missing, cfnum will receive NULL */
SInt32 value;
CFNumberGetValue (cfnum, kCFNumberSInt32Type, &value);
/* if cfnum was NULL, then we just crashed the app */
if (value != kCurrentSavedStateVersion) return kAudioUnitErr_InvalidPropertyValue;
This is the way that things are done for pretty much every key in
AUBase::RestoreState. I suggest that the code be changed to something
more like this:
CFNumberRef cfnum = reinterpret_cast<CFNumberRef>(CFDictionaryGetValue(dict, kVersionString));
if (cfnum == NULL)
return kAudioUnitErr_InvalidPropertyValue;
SInt32 value;
CFNumberGetValue (cfnum, kCFNumberSInt32Type, &value);
if (value != kCurrentSavedStateVersion) return kAudioUnitErr_InvalidPropertyValue;
or perhaps better still:
CFNumberRef cfnum;
if ( !CFDictionaryGetValueIfPresent(dict, kVersionString, (const void**)&cfnum) )
return kAudioUnitErr_InvalidPropertyValue;
SInt32 value;
CFNumberGetValue (cfnum, kCFNumberSInt32Type, &value);
if (value != kCurrentSavedStateVersion) return kAudioUnitErr_InvalidPropertyValue;
Marc
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.