Uploaded image for project: 'Xerces-C++'
  1. Xerces-C++
  2. XERCESC-1407

GrammarResolver has a bug with cached Grammar instances

    XMLWordPrintableJSON

Details

    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!

      Attachments

        1. patch.txt
          1 kB
          David N Bertoni

        Activity

          People

            dbertoni David N Bertoni
            dbertoni David N Bertoni
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: