boris-kolpackov commented on code in PR #54: URL: https://github.com/apache/xerces-c/pull/54#discussion_r1417168833
########## src/xercesc/internal/ReaderMgr.cpp: ########## @@ -873,33 +921,50 @@ bool ReaderMgr::isScanningPERefOutOfLiteral() const return false; } - bool ReaderMgr::pushReader( XMLReader* const reader , XMLEntityDecl* const entity) +{ + return pushReaderAdoptEntity(reader, entity, false); +} + +bool ReaderMgr::pushReaderAdoptEntity( XMLReader* const reader + , XMLEntityDecl* const entity + , const bool adoptEntity) { // // First, if an entity was passed, we have to confirm that this entity - // is not already on the entity stack. If so, then this is a recursive + // is not already on the reader stack. If so, then this is a recursive // entity expansion, so we issue an error and refuse to put the reader // on the stack. // // If there is no entity passed, then its not an entity being pushed, so // nothing to do. If there is no entity stack yet, then of coures it // cannot already be there. // - if (entity && fEntityStack) + if (entity && fReaderStack) { - const XMLSize_t count = fEntityStack->size(); + // @@ Strangely, we don't check the entity at the top of the stack + // (fCurReaderData). Is it a bug? + // + const XMLSize_t count = fReaderStack->size(); const XMLCh* const theName = entity->getName(); for (XMLSize_t index = 0; index < count; index++) { - const XMLEntityDecl* curDecl = fEntityStack->elementAt(index); + const XMLEntityDecl* curDecl = + fReaderStack->elementAt(index)->getEntity(); + if (curDecl) { if (XMLString::equals(theName, curDecl->getName())) { - // Oops, already there so delete reader and return + // Oops, already there so delete reader and entity and + // return. + // delete reader; + + if (adoptEntity) + delete entity; Review Comment: Ok, thanks, we will fixup the final version of the commit. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: c-dev-unsubscr...@xerces.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: c-dev-unsubscr...@xerces.apache.org For additional commands, e-mail: c-dev-h...@xerces.apache.org