mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-10 18:05:41 +08:00
Fix type overflow
This commit is contained in:
@ -174,7 +174,7 @@ namespace PdfWriter
|
|||||||
|
|
||||||
*pOffsets = new unsigned int[ushCount + 1];
|
*pOffsets = new unsigned int[ushCount + 1];
|
||||||
|
|
||||||
for (unsigned short i = 0; i <= ushCount; ++i)
|
for (unsigned int i = 0; i <= ushCount; ++i)
|
||||||
{
|
{
|
||||||
unsigned int unOffset = 0;
|
unsigned int unOffset = 0;
|
||||||
for (int i = 0; i < nOffSize; ++i)
|
for (int i = 0; i < nOffSize; ++i)
|
||||||
@ -248,6 +248,8 @@ namespace PdfWriter
|
|||||||
unsigned short nOperator = 0;
|
unsigned short nOperator = 0;
|
||||||
if (nOp == 12)
|
if (nOp == 12)
|
||||||
nOperator = (nOp << 8) | *pCFFData++;
|
nOperator = (nOp << 8) | *pCFFData++;
|
||||||
|
else
|
||||||
|
nOperator = nOp;
|
||||||
TopDICT.mTopDict[nOperator] = arrOperand;
|
TopDICT.mTopDict[nOperator] = arrOperand;
|
||||||
arrOperand.clear();
|
arrOperand.clear();
|
||||||
}
|
}
|
||||||
@ -713,7 +715,7 @@ namespace PdfWriter
|
|||||||
mNameToIndex.clear();
|
mNameToIndex.clear();
|
||||||
if (mTopDictIndex != NULL)
|
if (mTopDictIndex != NULL)
|
||||||
{
|
{
|
||||||
for (unsigned short i = 0; i < mFontsCount; ++i)
|
for (unsigned int i = 0; i < mFontsCount; ++i)
|
||||||
{
|
{
|
||||||
delete[] mTopDictIndex[i].mFDArray;
|
delete[] mTopDictIndex[i].mFDArray;
|
||||||
delete[] mTopDictIndex[i].mFDSelect;
|
delete[] mTopDictIndex[i].mFDSelect;
|
||||||
@ -730,7 +732,7 @@ namespace PdfWriter
|
|||||||
RELEASEARRAYOBJECTS(mGlobalSubrs.mCharStringsIndex);
|
RELEASEARRAYOBJECTS(mGlobalSubrs.mCharStringsIndex);
|
||||||
if (mCharStrings != NULL)
|
if (mCharStrings != NULL)
|
||||||
{
|
{
|
||||||
for (unsigned short i = 0; i < mFontsCount; ++i)
|
for (unsigned int i = 0; i < mFontsCount; ++i)
|
||||||
delete[] mCharStrings[i].mCharStringsIndex;
|
delete[] mCharStrings[i].mCharStringsIndex;
|
||||||
RELEASEARRAYOBJECTS(mCharStrings);
|
RELEASEARRAYOBJECTS(mCharStrings);
|
||||||
}
|
}
|
||||||
@ -864,7 +866,7 @@ namespace PdfWriter
|
|||||||
{
|
{
|
||||||
powerPart = powerPart * 10 + nibble[i];
|
powerPart = powerPart * 10 + nibble[i];
|
||||||
}
|
}
|
||||||
else if(hasFraction)
|
else if (hasFraction)
|
||||||
{
|
{
|
||||||
fractionPart = fractionPart * 10 + nibble[i];
|
fractionPart = fractionPart * 10 + nibble[i];
|
||||||
fractionDecimal *= 10;
|
fractionDecimal *= 10;
|
||||||
@ -879,11 +881,11 @@ namespace PdfWriter
|
|||||||
|
|
||||||
if (status)
|
if (status)
|
||||||
{
|
{
|
||||||
result = integerPart + fractionPart/fractionDecimal;
|
result = integerPart + fractionPart / fractionDecimal;
|
||||||
if(hasNegativePower || hasPositivePower)
|
if (hasNegativePower || hasPositivePower)
|
||||||
result = result * pow(10,hasNegativePower ? -powerPart : powerPart);
|
result = result * pow(10, hasNegativePower ? -powerPart : powerPart);
|
||||||
if(hasNegative)
|
if (hasNegative)
|
||||||
result = -1*result;
|
result = -result;
|
||||||
outValue = result;
|
outValue = result;
|
||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
@ -1007,7 +1009,7 @@ namespace PdfWriter
|
|||||||
BYTE offSizeForIndex = mPrimitivesReader->ReadUChar();
|
BYTE offSizeForIndex = mPrimitivesReader->ReadUChar();
|
||||||
*outOffsets = new unsigned long[outItemsCount + 1];
|
*outOffsets = new unsigned long[outItemsCount + 1];
|
||||||
|
|
||||||
for (unsigned short i = 0; i <= outItemsCount && !mPrimitivesReader->IsEof(); ++i)
|
for (unsigned int i = 0; i <= outItemsCount && !mPrimitivesReader->IsEof(); ++i)
|
||||||
(*outOffsets)[i] = mPrimitivesReader->ReadOffset(offSizeForIndex);
|
(*outOffsets)[i] = mPrimitivesReader->ReadOffset(offSizeForIndex);
|
||||||
|
|
||||||
return !mPrimitivesReader->IsEof();
|
return !mPrimitivesReader->IsEof();
|
||||||
@ -1025,7 +1027,7 @@ namespace PdfWriter
|
|||||||
mPrimitivesReader->Seek(offsets[0] - 1, SeekCur);
|
mPrimitivesReader->Seek(offsets[0] - 1, SeekCur);
|
||||||
|
|
||||||
BYTE* buffer;
|
BYTE* buffer;
|
||||||
for (unsigned short i = 0; i < mFontsCount; ++i)
|
for (unsigned int i = 0; i < mFontsCount; ++i)
|
||||||
{
|
{
|
||||||
unsigned int nLength = offsets[i + 1] - offsets[i];
|
unsigned int nLength = offsets[i + 1] - offsets[i];
|
||||||
buffer = new BYTE[nLength];
|
buffer = new BYTE[nLength];
|
||||||
@ -1055,7 +1057,7 @@ namespace PdfWriter
|
|||||||
|
|
||||||
mTopDictIndex = new TopDictInfo[dictionariesCount];
|
mTopDictIndex = new TopDictInfo[dictionariesCount];
|
||||||
|
|
||||||
for (unsigned short i = 0; i < dictionariesCount && status == true; ++i)
|
for (unsigned int i = 0; i < dictionariesCount && status; ++i)
|
||||||
status = ReadDict(offsets[i + 1] - offsets[i], mTopDictIndex[i].mTopDict);
|
status = ReadDict(offsets[i + 1] - offsets[i], mTopDictIndex[i].mTopDict);
|
||||||
|
|
||||||
delete[] offsets;
|
delete[] offsets;
|
||||||
@ -1138,7 +1140,7 @@ namespace PdfWriter
|
|||||||
}
|
}
|
||||||
|
|
||||||
// now create the string to SID map
|
// now create the string to SID map
|
||||||
for ( i = 0; i < N_STD_STRINGS; ++i)
|
for (i = 0; i < N_STD_STRINGS; ++i)
|
||||||
mStringToSID.insert(CharPToUShortMap::value_type(scStandardStrings[i], i));
|
mStringToSID.insert(CharPToUShortMap::value_type(scStandardStrings[i], i));
|
||||||
for (; i < N_STD_STRINGS + mStringsCount; ++i)
|
for (; i < N_STD_STRINGS + mStringsCount; ++i)
|
||||||
mStringToSID.insert(CharPToUShortMap::value_type(mStrings[i - N_STD_STRINGS], i));
|
mStringToSID.insert(CharPToUShortMap::value_type(mStrings[i - N_STD_STRINGS], i));
|
||||||
@ -1172,10 +1174,10 @@ namespace PdfWriter
|
|||||||
|
|
||||||
long long dataStartPosition = mPrimitivesReader->Tell();
|
long long dataStartPosition = mPrimitivesReader->Tell();
|
||||||
|
|
||||||
for (unsigned short i = 0; i < outSubrsCount; ++i)
|
for (unsigned int i = 0; i < outSubrsCount; ++i)
|
||||||
{
|
{
|
||||||
(*outSubrsIndex)[i].mStartPosition = dataStartPosition + offsets[i] - 1;
|
(*outSubrsIndex)[i].mStartPosition = dataStartPosition + offsets[i] - 1;
|
||||||
(*outSubrsIndex)[i].mEndPosition = dataStartPosition + offsets[i+1] - 1;
|
(*outSubrsIndex)[i].mEndPosition = dataStartPosition + offsets[i + 1] - 1;
|
||||||
(*outSubrsIndex)[i].mIndex = i;
|
(*outSubrsIndex)[i].mIndex = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1191,9 +1193,9 @@ namespace PdfWriter
|
|||||||
mCharStrings = new CharStrings[mFontsCount];
|
mCharStrings = new CharStrings[mFontsCount];
|
||||||
bool status = true;
|
bool status = true;
|
||||||
|
|
||||||
for (unsigned short i = 0; i < mFontsCount && status; ++i)
|
for (unsigned int i = 0; i < mFontsCount && status; ++i)
|
||||||
{
|
{
|
||||||
long long charStringsPosition = GetCharStringsPosition(i);
|
long long charStringsPosition = GetCharStringsPosition(i);
|
||||||
mCharStrings[i].mCharStringsType = (BYTE)GetCharStringType(i);
|
mCharStrings[i].mCharStringsType = (BYTE)GetCharStringType(i);
|
||||||
if (0 == charStringsPosition)
|
if (0 == charStringsPosition)
|
||||||
{
|
{
|
||||||
@ -1235,7 +1237,7 @@ namespace PdfWriter
|
|||||||
mPrivateDicts = new PrivateDictInfo[mFontsCount];
|
mPrivateDicts = new PrivateDictInfo[mFontsCount];
|
||||||
bool status = true;
|
bool status = true;
|
||||||
|
|
||||||
for (unsigned short i = 0; i < mFontsCount && status; ++i)
|
for (unsigned int i = 0; i < mFontsCount && status; ++i)
|
||||||
status = ReadPrivateDict(mTopDictIndex[i].mTopDict, mPrivateDicts + i);
|
status = ReadPrivateDict(mTopDictIndex[i].mTopDict, mPrivateDicts + i);
|
||||||
|
|
||||||
if (!status)
|
if (!status)
|
||||||
@ -1268,7 +1270,7 @@ namespace PdfWriter
|
|||||||
// scan all subrs of all included fonts
|
// scan all subrs of all included fonts
|
||||||
bool status = true;
|
bool status = true;
|
||||||
|
|
||||||
for (unsigned short i=0; i < mFontsCount && status; ++i)
|
for (unsigned int i = 0; i < mFontsCount && status; ++i)
|
||||||
status = ReadLocalSubrsForPrivateDict(mPrivateDicts + i, (BYTE)GetCharStringType(i));
|
status = ReadLocalSubrsForPrivateDict(mPrivateDicts + i, (BYTE)GetCharStringType(i));
|
||||||
|
|
||||||
if (!status)
|
if (!status)
|
||||||
@ -1307,7 +1309,7 @@ namespace PdfWriter
|
|||||||
LongFilePositionTypeToCharSetInfoMap offsetToIndex;
|
LongFilePositionTypeToCharSetInfoMap offsetToIndex;
|
||||||
LongFilePositionTypeToCharSetInfoMap::iterator it;
|
LongFilePositionTypeToCharSetInfoMap::iterator it;
|
||||||
|
|
||||||
for (unsigned short i = 0; i < mFontsCount && status; ++i)
|
for (unsigned int i = 0; i < mFontsCount && status; ++i)
|
||||||
{
|
{
|
||||||
long long charsetPosition = GetCharsetPosition(i);
|
long long charsetPosition = GetCharsetPosition(i);
|
||||||
it = offsetToIndex.find(charsetPosition);
|
it = offsetToIndex.find(charsetPosition);
|
||||||
@ -1353,7 +1355,7 @@ namespace PdfWriter
|
|||||||
LongFilePositionTypeToEncodingsInfoMap offsetToEncoding;
|
LongFilePositionTypeToEncodingsInfoMap offsetToEncoding;
|
||||||
LongFilePositionTypeToEncodingsInfoMap::iterator it;
|
LongFilePositionTypeToEncodingsInfoMap::iterator it;
|
||||||
|
|
||||||
for (unsigned short i = 0; i < mFontsCount && status; ++i)
|
for (unsigned int i = 0; i < mFontsCount && status; ++i)
|
||||||
{
|
{
|
||||||
long long encodingPosition = GetEncodingPosition(i);
|
long long encodingPosition = GetEncodingPosition(i);
|
||||||
it = offsetToEncoding.find(encodingPosition);
|
it = offsetToEncoding.find(encodingPosition);
|
||||||
@ -1369,8 +1371,7 @@ namespace PdfWriter
|
|||||||
|
|
||||||
if (!status)
|
if (!status)
|
||||||
return status;
|
return status;
|
||||||
else
|
return !mPrimitivesReader->IsEof();
|
||||||
return !mPrimitivesReader->IsEof();
|
|
||||||
}
|
}
|
||||||
void CCFFReader::ReadEncoding(EncodingsInfo* inEncoding, long long inEncodingPosition)
|
void CCFFReader::ReadEncoding(EncodingsInfo* inEncoding, long long inEncodingPosition)
|
||||||
{
|
{
|
||||||
@ -1451,7 +1452,7 @@ namespace PdfWriter
|
|||||||
void CCFFReader::SetupSIDToGlyphMapWithStandard(const unsigned short* inStandardCharSet, unsigned short inStandardCharSetLength, UShortToCharStringMap& ioCharMap, const CharStrings& inCharStrings)
|
void CCFFReader::SetupSIDToGlyphMapWithStandard(const unsigned short* inStandardCharSet, unsigned short inStandardCharSetLength, UShortToCharStringMap& ioCharMap, const CharStrings& inCharStrings)
|
||||||
{
|
{
|
||||||
ioCharMap.insert(UShortToCharStringMap::value_type(0, inCharStrings.mCharStringsIndex));
|
ioCharMap.insert(UShortToCharStringMap::value_type(0, inCharStrings.mCharStringsIndex));
|
||||||
for (unsigned short i = 1; i < inCharStrings.mCharStringsCount && i < inStandardCharSetLength;++i)
|
for (unsigned int i = 1; i < inCharStrings.mCharStringsCount && i < inStandardCharSetLength;++i)
|
||||||
ioCharMap.insert(UShortToCharStringMap::value_type(inStandardCharSet[i], inCharStrings.mCharStringsIndex + i));
|
ioCharMap.insert(UShortToCharStringMap::value_type(inStandardCharSet[i], inCharStrings.mCharStringsIndex + i));
|
||||||
}
|
}
|
||||||
bool CCFFReader::ReadFormat0Charset(bool inIsCID, UShortToCharStringMap& ioGlyphMap, unsigned short** inSIDArray, const CharStrings& inCharStrings)
|
bool CCFFReader::ReadFormat0Charset(bool inIsCID, UShortToCharStringMap& ioGlyphMap, unsigned short** inSIDArray, const CharStrings& inCharStrings)
|
||||||
@ -1464,12 +1465,12 @@ namespace PdfWriter
|
|||||||
|
|
||||||
if (inIsCID)
|
if (inIsCID)
|
||||||
{
|
{
|
||||||
for (unsigned short i = 1; i < inCharStrings.mCharStringsCount; ++i)
|
for (unsigned int i = 1; i < inCharStrings.mCharStringsCount; ++i)
|
||||||
(*inSIDArray)[i] = mPrimitivesReader->ReadUShort();
|
(*inSIDArray)[i] = mPrimitivesReader->ReadUShort();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (unsigned short i = 1; i < inCharStrings.mCharStringsCount; ++i)
|
for (unsigned int i = 1; i < inCharStrings.mCharStringsCount; ++i)
|
||||||
{
|
{
|
||||||
unsigned short sid = mPrimitivesReader->ReadUShort();
|
unsigned short sid = mPrimitivesReader->ReadUShort();
|
||||||
(*inSIDArray)[i] = sid;
|
(*inSIDArray)[i] = sid;
|
||||||
@ -1516,7 +1517,7 @@ namespace PdfWriter
|
|||||||
}
|
}
|
||||||
bool CCFFReader::ReadFormat2Charset(bool inIsCID, UShortToCharStringMap& ioGlyphMap, unsigned short** inSIDArray, const CharStrings& inCharStrings)
|
bool CCFFReader::ReadFormat2Charset(bool inIsCID, UShortToCharStringMap& ioGlyphMap, unsigned short** inSIDArray, const CharStrings& inCharStrings)
|
||||||
{
|
{
|
||||||
if(!inIsCID)
|
if (!inIsCID)
|
||||||
ioGlyphMap.insert(UShortToCharStringMap::value_type(0, inCharStrings.mCharStringsIndex));
|
ioGlyphMap.insert(UShortToCharStringMap::value_type(0, inCharStrings.mCharStringsIndex));
|
||||||
*inSIDArray = new unsigned short[inCharStrings.mCharStringsCount];
|
*inSIDArray = new unsigned short[inCharStrings.mCharStringsCount];
|
||||||
(*inSIDArray)[0] = 0;
|
(*inSIDArray)[0] = 0;
|
||||||
@ -1530,7 +1531,7 @@ namespace PdfWriter
|
|||||||
{
|
{
|
||||||
sid = mPrimitivesReader->ReadUShort();
|
sid = mPrimitivesReader->ReadUShort();
|
||||||
left = mPrimitivesReader->ReadUShort();
|
left = mPrimitivesReader->ReadUShort();
|
||||||
for (unsigned short i = 0; i <= left && glyphIndex < inCharStrings.mCharStringsCount; ++i, ++glyphIndex)
|
for (unsigned int i = 0; i <= left && glyphIndex < inCharStrings.mCharStringsCount; ++i, ++glyphIndex)
|
||||||
(*inSIDArray)[glyphIndex] = sid + i;
|
(*inSIDArray)[glyphIndex] = sid + i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1540,7 +1541,7 @@ namespace PdfWriter
|
|||||||
{
|
{
|
||||||
sid = mPrimitivesReader->ReadUShort();
|
sid = mPrimitivesReader->ReadUShort();
|
||||||
left = mPrimitivesReader->ReadUShort();
|
left = mPrimitivesReader->ReadUShort();
|
||||||
for (unsigned short i = 0; i <= left && glyphIndex < inCharStrings.mCharStringsCount; ++i ,++glyphIndex)
|
for (unsigned int i = 0; i <= left && glyphIndex < inCharStrings.mCharStringsCount; ++i ,++glyphIndex)
|
||||||
{
|
{
|
||||||
ioGlyphMap.insert(UShortToCharStringMap::value_type(sid + i, inCharStrings.mCharStringsIndex + glyphIndex));
|
ioGlyphMap.insert(UShortToCharStringMap::value_type(sid + i, inCharStrings.mCharStringsIndex + glyphIndex));
|
||||||
(*inSIDArray)[glyphIndex] = sid + i;
|
(*inSIDArray)[glyphIndex] = sid + i;
|
||||||
@ -1561,7 +1562,7 @@ namespace PdfWriter
|
|||||||
{
|
{
|
||||||
bool status = true;
|
bool status = true;
|
||||||
|
|
||||||
for (unsigned short i = 0; i < mFontsCount && status; ++i)
|
for (unsigned int i = 0; i < mFontsCount && status; ++i)
|
||||||
{
|
{
|
||||||
// CID font will be identified by the existance of the ROS entry
|
// CID font will be identified by the existance of the ROS entry
|
||||||
if (mTopDictIndex[i].mTopDict.find(scROS) != mTopDictIndex[i].mTopDict.end())
|
if (mTopDictIndex[i].mTopDict.find(scROS) != mTopDictIndex[i].mTopDict.end())
|
||||||
@ -1644,7 +1645,7 @@ namespace PdfWriter
|
|||||||
{
|
{
|
||||||
BYTE fdIndex;
|
BYTE fdIndex;
|
||||||
|
|
||||||
for (unsigned short i = 0; i < glyphCount && !mPrimitivesReader->IsEof(); ++i)
|
for (unsigned int i = 0; i < glyphCount && !mPrimitivesReader->IsEof(); ++i)
|
||||||
{
|
{
|
||||||
fdIndex = mPrimitivesReader->ReadUChar();
|
fdIndex = mPrimitivesReader->ReadUChar();
|
||||||
if (!mPrimitivesReader->IsEof())
|
if (!mPrimitivesReader->IsEof())
|
||||||
@ -1662,12 +1663,12 @@ namespace PdfWriter
|
|||||||
if (!mPrimitivesReader->IsEof())
|
if (!mPrimitivesReader->IsEof())
|
||||||
{
|
{
|
||||||
firstGlyphIndex = mPrimitivesReader->ReadUShort();
|
firstGlyphIndex = mPrimitivesReader->ReadUShort();
|
||||||
for (unsigned short i = 0; i < rangesCount && !mPrimitivesReader->IsEof(); ++i)
|
for (unsigned int i = 0; i < rangesCount && !mPrimitivesReader->IsEof(); ++i)
|
||||||
{
|
{
|
||||||
fdIndex = mPrimitivesReader->ReadUChar();
|
fdIndex = mPrimitivesReader->ReadUChar();
|
||||||
nextRangeGlyphIndex = mPrimitivesReader->ReadUShort();
|
nextRangeGlyphIndex = mPrimitivesReader->ReadUShort();
|
||||||
if (!mPrimitivesReader->IsEof())
|
if (!mPrimitivesReader->IsEof())
|
||||||
for (unsigned short j = firstGlyphIndex; j < nextRangeGlyphIndex; ++j)
|
for (unsigned int j = firstGlyphIndex; j < nextRangeGlyphIndex; ++j)
|
||||||
mTopDictIndex[inFontIndex].mFDSelect[j] = mTopDictIndex[inFontIndex].mFDArray + fdIndex;
|
mTopDictIndex[inFontIndex].mFDSelect[j] = mTopDictIndex[inFontIndex].mFDArray + fdIndex;
|
||||||
firstGlyphIndex = nextRangeGlyphIndex;
|
firstGlyphIndex = nextRangeGlyphIndex;
|
||||||
}
|
}
|
||||||
@ -2023,7 +2024,7 @@ namespace PdfWriter
|
|||||||
// skip the next 6
|
// skip the next 6
|
||||||
mPrimitivesReader->Seek(6, SeekCur);
|
mPrimitivesReader->Seek(6, SeekCur);
|
||||||
|
|
||||||
for (unsigned short i = 0; i < mTablesCount; ++i)
|
for (unsigned int i = 0; i < mTablesCount; ++i)
|
||||||
{
|
{
|
||||||
tableTag = mPrimitivesReader->ReadUInt();
|
tableTag = mPrimitivesReader->ReadUInt();
|
||||||
tableEntry.CheckSum = mPrimitivesReader->ReadUInt();
|
tableEntry.CheckSum = mPrimitivesReader->ReadUInt();
|
||||||
@ -2600,7 +2601,7 @@ namespace PdfWriter
|
|||||||
pCFFData = ReadIndexHeader(pCFFData, &pOffsets, ushDictCount);
|
pCFFData = ReadIndexHeader(pCFFData, &pOffsets, ushDictCount);
|
||||||
|
|
||||||
CTopDictInfo* pTopDICT = new CTopDictInfo[ushDictCount];
|
CTopDictInfo* pTopDICT = new CTopDictInfo[ushDictCount];
|
||||||
for (unsigned short i = 0; i < ushDictCount; ++i)
|
for (unsigned int i = 0; i < ushDictCount; ++i)
|
||||||
ReadTopDICT(pCFFData + pOffsets[i] - 1, pCFFData + pOffsets[i + 1] - 1, pTopDICT[i]);
|
ReadTopDICT(pCFFData + pOffsets[i] - 1, pCFFData + pOffsets[i + 1] - 1, pTopDICT[i]);
|
||||||
pCFFData += pOffsets[ushDictCount] - 1;
|
pCFFData += pOffsets[ushDictCount] - 1;
|
||||||
RELEASEARRAYOBJECTS(pOffsets);
|
RELEASEARRAYOBJECTS(pOffsets);
|
||||||
@ -2613,7 +2614,7 @@ namespace PdfWriter
|
|||||||
pCFFData = ReadIndexHeader(pCFFData, &pOffsets, ushStringCount);
|
pCFFData = ReadIndexHeader(pCFFData, &pOffsets, ushStringCount);
|
||||||
|
|
||||||
BYTE** pStrings = new BYTE*[ushStringCount];
|
BYTE** pStrings = new BYTE*[ushStringCount];
|
||||||
for (unsigned short i = 0; i < ushStringCount; ++i)
|
for (unsigned int i = 0; i < ushStringCount; ++i)
|
||||||
{
|
{
|
||||||
unsigned int unLength = pOffsets[i + 1] - pOffsets[i];
|
unsigned int unLength = pOffsets[i + 1] - pOffsets[i];
|
||||||
pStrings[i] = new BYTE[unLength + 1];
|
pStrings[i] = new BYTE[unLength + 1];
|
||||||
@ -2739,14 +2740,14 @@ namespace PdfWriter
|
|||||||
pOutputStream->WriteUChar(nStringsCount1 & 0xff); // count (LSB)
|
pOutputStream->WriteUChar(nStringsCount1 & 0xff); // count (LSB)
|
||||||
|
|
||||||
unsigned int unTotalSize = 0;
|
unsigned int unTotalSize = 0;
|
||||||
for (unsigned short i = 0; i < ushStringCount; ++i)
|
for (unsigned int i = 0; i < ushStringCount; ++i)
|
||||||
unTotalSize += strlen((char *)pStrings[i]);
|
unTotalSize += strlen((char *)pStrings[i]);
|
||||||
unTotalSize += sOptionalEmbeddedPostscript.size();
|
unTotalSize += sOptionalEmbeddedPostscript.size();
|
||||||
nSizeOfOffset = GetMostCompressedOffsetSize(unTotalSize + 1);
|
nSizeOfOffset = GetMostCompressedOffsetSize(unTotalSize + 1);
|
||||||
pOutputStream->WriteUChar(nSizeOfOffset); // offset size
|
pOutputStream->WriteUChar(nSizeOfOffset); // offset size
|
||||||
|
|
||||||
unsigned int unCurOffset = 1;
|
unsigned int unCurOffset = 1;
|
||||||
for (unsigned short i = 0; i < ushStringCount; ++i)
|
for (unsigned int i = 0; i < ushStringCount; ++i)
|
||||||
{
|
{
|
||||||
WriteOffset(unCurOffset, nSizeOfOffset, pOutputStream);; // offset
|
WriteOffset(unCurOffset, nSizeOfOffset, pOutputStream);; // offset
|
||||||
unCurOffset += strlen((char *)pStrings[i]);
|
unCurOffset += strlen((char *)pStrings[i]);
|
||||||
@ -2755,7 +2756,7 @@ namespace PdfWriter
|
|||||||
unCurOffset += sOptionalEmbeddedPostscript.size();
|
unCurOffset += sOptionalEmbeddedPostscript.size();
|
||||||
WriteOffset(unCurOffset, nSizeOfOffset, pOutputStream);; // offset
|
WriteOffset(unCurOffset, nSizeOfOffset, pOutputStream);; // offset
|
||||||
|
|
||||||
for (unsigned short i = 0; i < ushStringCount; ++i)
|
for (unsigned int i = 0; i < ushStringCount; ++i)
|
||||||
pOutputStream->Write(pStrings[i], strlen((char *)pStrings[i]));
|
pOutputStream->Write(pStrings[i], strlen((char *)pStrings[i]));
|
||||||
pOutputStream->WriteStr(sOptionalEmbeddedPostscript.c_str());
|
pOutputStream->WriteStr(sOptionalEmbeddedPostscript.c_str());
|
||||||
}
|
}
|
||||||
@ -2834,7 +2835,7 @@ namespace PdfWriter
|
|||||||
// ------
|
// ------
|
||||||
|
|
||||||
RELEASEARRAYOBJECTS(pTopDICT);
|
RELEASEARRAYOBJECTS(pTopDICT);
|
||||||
for (unsigned short i = 0; i < ushStringCount; ++i)
|
for (unsigned int i = 0; i < ushStringCount; ++i)
|
||||||
RELEASEARRAYOBJECTS(pStrings[i]);
|
RELEASEARRAYOBJECTS(pStrings[i]);
|
||||||
RELEASEARRAYOBJECTS(pStrings);
|
RELEASEARRAYOBJECTS(pStrings);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -149,7 +149,7 @@ namespace PdfWriter
|
|||||||
unsigned int CStream::ReadOffset(BYTE nOffset)
|
unsigned int CStream::ReadOffset(BYTE nOffset)
|
||||||
{
|
{
|
||||||
unsigned int nRes = 0;
|
unsigned int nRes = 0;
|
||||||
if (nOffset < 1 || nOffset > 4)
|
if (nOffset < 1 || nOffset > 4 || !CheckSize(nOffset))
|
||||||
return nRes;
|
return nRes;
|
||||||
for (BYTE i = 0; i < nOffset; ++i)
|
for (BYTE i = 0; i < nOffset; ++i)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user