Ticket #54356: patch-lib-xmlparse.c.diff

File patch-lib-xmlparse.c.diff, 5.1 KB (added by Schamschula (Marius Schamschula), 7 years ago)
  • lib/xmlparse.c

    old new  
    623623#define defaultExpandInternalEntities \
    624624        (parser->m_defaultExpandInternalEntities)
    625625#define tagLevel (parser->m_tagLevel)
    626 #define buffer (parser->m_buffer)
     626#define xbuffer (parser->m_buffer)
    627627#define bufferPtr (parser->m_bufferPtr)
    628628#define bufferEnd (parser->m_bufferEnd)
    629629#define parseEndByteIndex (parser->m_parseEndByteIndex)
     
    901901  if (!parser)
    902902    return parser;
    903903
    904   buffer = NULL;
     904  xbuffer = NULL;
    905905  bufferLim = NULL;
    906906
    907907  attsSize = INIT_ATTS_SIZE;
     
    10171017  attlistDeclHandler = NULL;
    10181018  entityDeclHandler = NULL;
    10191019  xmlDeclHandler = NULL;
    1020   bufferPtr = buffer;
    1021   bufferEnd = buffer;
     1020  bufferPtr = xbuffer;
     1021  bufferEnd = xbuffer;
    10221022  parseEndByteIndex = 0;
    10231023  parseEndPtr = NULL;
    10241024  declElementType = NULL;
     
    13711371  FREE((void *)attInfo);
    13721372#endif
    13731373  FREE(groupConnector);
    1374   FREE(buffer);
     1374  FREE(xbuffer);
    13751375  FREE(dataBuf);
    13761376  FREE(nsAtts);
    13771377  FREE(unknownEncodingMem);
     
    18411841    XmlUpdatePosition(encoding, positionPtr, end, &position);
    18421842    nLeftOver = s + len - end;
    18431843    if (nLeftOver) {
    1844       if (buffer == NULL || nLeftOver > bufferLim - buffer) {
     1844      if (xbuffer == NULL || nLeftOver > bufferLim - xbuffer) {
    18451845        /* avoid _signed_ integer overflow */
    18461846        char *temp = NULL;
    18471847        const int bytesToAllocate = (int)((unsigned)len * 2U);
    18481848        if (bytesToAllocate > 0) {
    1849           temp = (buffer == NULL
     1849          temp = (xbuffer == NULL
    18501850                ? (char *)MALLOC(bytesToAllocate)
    1851                 : (char *)REALLOC(buffer, bytesToAllocate));
     1851                : (char *)REALLOC(xbuffer, bytesToAllocate));
    18521852        }
    18531853        if (temp == NULL) {
    18541854          errorCode = XML_ERROR_NO_MEMORY;
     
    18561856          processor = errorProcessor;
    18571857          return XML_STATUS_ERROR;
    18581858        }
    1859         buffer = temp;
    1860         bufferLim = buffer + bytesToAllocate;
     1859        xbuffer = temp;
     1860        bufferLim = xbuffer + bytesToAllocate;
    18611861      }
    1862       memcpy(buffer, end, nLeftOver);
     1862      memcpy(xbuffer, end, nLeftOver);
    18631863    }
    1864     bufferPtr = buffer;
    1865     bufferEnd = buffer + nLeftOver;
     1864    bufferPtr = xbuffer;
     1865    bufferEnd = xbuffer + nLeftOver;
    18661866    positionPtr = bufferPtr;
    18671867    parseEndPtr = bufferEnd;
    18681868    eventPtr = bufferPtr;
     
    19691969      return NULL;
    19701970    }
    19711971#ifdef XML_CONTEXT_BYTES
    1972     keep = (int)(bufferPtr - buffer);
     1972    keep = (int)(bufferPtr - xbuffer);
    19731973    if (keep > XML_CONTEXT_BYTES)
    19741974      keep = XML_CONTEXT_BYTES;
    19751975    neededSize += keep;
    19761976#endif  /* defined XML_CONTEXT_BYTES */
    1977     if (neededSize  <= bufferLim - buffer) {
     1977    if (neededSize  <= bufferLim - xbuffer) {
    19781978#ifdef XML_CONTEXT_BYTES
    1979       if (keep < bufferPtr - buffer) {
    1980         int offset = (int)(bufferPtr - buffer) - keep;
    1981         memmove(buffer, &buffer[offset], bufferEnd - bufferPtr + keep);
     1979      if (keep < bufferPtr - xbuffer) {
     1980        int offset = (int)(bufferPtr - xbuffer) - keep;
     1981        memmove(xbuffer, &xbuffer[offset], bufferEnd - bufferPtr + keep);
    19821982        bufferEnd -= offset;
    19831983        bufferPtr -= offset;
    19841984      }
    19851985#else
    1986       memmove(buffer, bufferPtr, bufferEnd - bufferPtr);
    1987       bufferEnd = buffer + (bufferEnd - bufferPtr);
    1988       bufferPtr = buffer;
     1986      memmove(xbuffer, bufferPtr, bufferEnd - bufferPtr);
     1987      bufferEnd = xbuffer + (bufferEnd - bufferPtr);
     1988      bufferPtr = xbuffer;
    19891989#endif  /* not defined XML_CONTEXT_BYTES */
    19901990    }
    19911991    else {
     
    20092009      bufferLim = newBuf + bufferSize;
    20102010#ifdef XML_CONTEXT_BYTES
    20112011      if (bufferPtr) {
    2012         int keep = (int)(bufferPtr - buffer);
     2012        int keep = (int)(bufferPtr - xbuffer);
    20132013        if (keep > XML_CONTEXT_BYTES)
    20142014          keep = XML_CONTEXT_BYTES;
    20152015        memcpy(newBuf, &bufferPtr[-keep], bufferEnd - bufferPtr + keep);
    2016         FREE(buffer);
    2017         buffer = newBuf;
    2018         bufferEnd = buffer + (bufferEnd - bufferPtr) + keep;
    2019         bufferPtr = buffer + keep;
     2016        FREE(xbuffer);
     2017        xbuffer = newBuf;
     2018        bufferEnd = xbuffer + (bufferEnd - bufferPtr) + keep;
     2019        bufferPtr = xbuffer + keep;
    20202020      }
    20212021      else {
    20222022        bufferEnd = newBuf + (bufferEnd - bufferPtr);
    2023         bufferPtr = buffer = newBuf;
     2023        bufferPtr = xbuffer = newBuf;
    20242024      }
    20252025#else
    20262026      if (bufferPtr) {
    20272027        memcpy(newBuf, bufferPtr, bufferEnd - bufferPtr);
    2028         FREE(buffer);
     2028        FREE(xbuffer);
    20292029      }
    20302030      bufferEnd = newBuf + (bufferEnd - bufferPtr);
    2031       bufferPtr = buffer = newBuf;
     2031      bufferPtr = xbuffer = newBuf;
    20322032#endif  /* not defined XML_CONTEXT_BYTES */
    20332033    }
    20342034    eventPtr = eventEndPtr = NULL;
     
    21522152#ifdef XML_CONTEXT_BYTES
    21532153  if (parser == NULL)
    21542154    return NULL;
    2155   if (eventPtr && buffer) {
     2155  if (eventPtr && xbuffer) {
    21562156    if (offset != NULL)
    2157       *offset = (int)(eventPtr - buffer);
     2157      *offset = (int)(eventPtr - xbuffer);
    21582158    if (size != NULL)
    2159       *size   = (int)(bufferEnd - buffer);
    2160     return buffer;
     2159      *size   = (int)(bufferEnd - xbuffer);
     2160    return xbuffer;
    21612161  }
    21622162#else
    21632163  (void)parser;