Details
-
Bug
-
Status: Closed
-
Critical
-
Resolution: Fixed
-
2.6.0
-
None
Description
GrammarResolver will fail to orphan a Grammar instance if the XMLGrammarPool instance it is using refused to cache the grammar when it was first added. This can be seen by the the following code in GrammarResolver::putGrammar():
/***
- the grammar will be either in the grammarpool, or in the grammarbucket
*/
if (!fCacheGrammar || !fGrammarPool->cacheGrammar(grammarToAdopt))
{
// either we aren't caching or the grammar pool doesn't want it
// so we need to look after it
fGrammarBucket->put( (void*) grammarToAdopt->getGrammarDescription()->getGrammarKey(), grammarToAdopt );
If the second branch of the if fails, the GrammarResolver will put the Grammar instance in fGrammarBucket. However, in orphanGrammar(), it fails to check to see if the instance was put there. This can lead to a situation where the Grammar instance is in fGrammarBucket twice, which will result in an attempt to delete twice, as it will be in fGrammarBucket with two different keys.
I am attaching a patch. Could other committers please review? Thanks!