From f5eaf99f6fd80c1abf29c1e7bbf11bd6ffcdb013 Mon Sep 17 00:00:00 2001 From: iaom Date: Fri, 28 Apr 2023 16:51:51 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E4=B8=80=E5=A4=84=E6=BD=9C?= =?UTF-8?q?=E5=9C=A8=E7=9A=84=E5=B4=A9=E6=BA=83=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libsearch/parser/binary-parser.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/libsearch/parser/binary-parser.cpp b/libsearch/parser/binary-parser.cpp index 935b6f5..d2aca65 100644 --- a/libsearch/parser/binary-parser.cpp +++ b/libsearch/parser/binary-parser.cpp @@ -4562,19 +4562,26 @@ static void vName2String(char *szName, const UCHAR *aucBytes, size_t tNameSize) } /* end of vName2String */ -void vAdd2PropModList(const UCHAR *aucPropMod) { +bool vAdd2PropModList(const UCHAR *aucPropMod) { size_t tSize, tLen; if(tNextFree >= tMaxElements) { tMaxElements += ELEMENTS_TO_ADD; tSize = tMaxElements * sizeof(UCHAR **); - ppAnchor = (UCHAR**)xrealloc(ppAnchor, tSize); + void *pvTmp; + pvTmp = realloc(ppAnchor, tSize); + if(pvTmp) { + ppAnchor = (UCHAR**)pvTmp; + } else { + return false; + } } tLen = 2 + (size_t)usGetWord(0, aucPropMod); ppAnchor[tNextFree] = (UCHAR*)xmalloc(tLen); memcpy(ppAnchor[tNextFree], aucPropMod, tLen); tNextFree++; + return true; } /* end of vAdd2PropModList */ static void vComputePPSlevels(ppsEntryType *atPPSlist, ppsEntryType *pNode, @@ -4940,7 +4947,9 @@ bool KBinaryParser::read8DocText(FILE *pFile, const ppsInfoType *pPPS, } if(iType == 1) { iLen = (int)usGetWord(lOff, aucBuffer); - vAdd2PropModList(aucBuffer + lOff); + if(!vAdd2PropModList(aucBuffer + lOff)) { + return false; + } lOff += (long)iLen + 2; continue; }