Kaydet (Commit) 313e304b authored tarafından Caolán McNamara's avatar Caolán McNamara

coverity#704089 Unchecked return value

rework code a little to help coverity out

Change-Id: I4aa253a579153ad389d4667a9676fff04aa00a34
üst 7694719c
...@@ -242,30 +242,29 @@ static void ProcessTables(TrueTypeCreator *); ...@@ -242,30 +242,29 @@ static void ProcessTables(TrueTypeCreator *);
int StreamToMemory(TrueTypeCreator *_this, sal_uInt8 **ptr, sal_uInt32 *length) int StreamToMemory(TrueTypeCreator *_this, sal_uInt8 **ptr, sal_uInt32 *length)
{ {
sal_uInt16 numTables, searchRange=1, entrySelector=0, rangeShift; sal_uInt16 searchRange=1, entrySelector=0, rangeShift;
sal_uInt32 s, offset, checkSumAdjustment = 0; sal_uInt32 s, offset, checkSumAdjustment = 0;
sal_uInt32 *p; sal_uInt32 *p;
int i=0, n;
sal_uInt8 *head = NULL; /* saved pointer to the head table data for checkSumAdjustment calculation */ sal_uInt8 *head = NULL; /* saved pointer to the head table data for checkSumAdjustment calculation */
if ((n = listCount(_this->tables)) == 0) return SF_TTFORMAT; if (listIsEmpty(_this->tables)) return SF_TTFORMAT;
ProcessTables(_this); ProcessTables(_this);
/* ProcessTables() adds 'loca' and 'hmtx' */ /* ProcessTables() adds 'loca' and 'hmtx' */
n = listCount(_this->tables); sal_uInt16 numTables = listCount(_this->tables);
numTables = (sal_uInt16) n;
TableEntry* te = (TableEntry*)scalloc(n, sizeof(TableEntry)); TableEntry* te = (TableEntry*)scalloc(numTables, sizeof(TableEntry));
TableEntry* e = te;
listToFirst(_this->tables); listToFirst(_this->tables);
for (i = 0; i < n; i++) { do {
GetRawData((TrueTypeTable *) listCurrent(_this->tables), &te[i].data, &te[i].length, &te[i].tag); GetRawData((TrueTypeTable *)listCurrent(_this->tables), &e->data, &e->length, &e->tag);
listNext(_this->tables); ++e;
} } while (listNext(_this->tables));
qsort(te, n, sizeof(TableEntry), TableEntryCompareF); qsort(te, numTables, sizeof(TableEntry), TableEntryCompareF);
do { do {
searchRange *= 2; searchRange *= 2;
...@@ -276,9 +275,9 @@ int StreamToMemory(TrueTypeCreator *_this, sal_uInt8 **ptr, sal_uInt32 *length) ...@@ -276,9 +275,9 @@ int StreamToMemory(TrueTypeCreator *_this, sal_uInt8 **ptr, sal_uInt32 *length)
entrySelector--; entrySelector--;
rangeShift = numTables * 16 - searchRange; rangeShift = numTables * 16 - searchRange;
s = offset = 12 + 16 * n; s = offset = 12 + 16 * numTables;
for (i = 0; i < n; i++) { for (int i = 0; i < numTables; ++i) {
s += (te[i].length + 3) & (sal_uInt32) ~3; s += (te[i].length + 3) & (sal_uInt32) ~3;
/* if ((te[i].length & 3) != 0) s += (4 - (te[i].length & 3)) & 3; */ /* if ((te[i].length & 3) != 0) s += (4 - (te[i].length & 3)) & 3; */
} }
...@@ -293,7 +292,7 @@ int StreamToMemory(TrueTypeCreator *_this, sal_uInt8 **ptr, sal_uInt32 *length) ...@@ -293,7 +292,7 @@ int StreamToMemory(TrueTypeCreator *_this, sal_uInt8 **ptr, sal_uInt32 *length)
PutUInt16(rangeShift, ttf, 10, 1); PutUInt16(rangeShift, ttf, 10, 1);
/* Table Directory */ /* Table Directory */
for (i = 0; i < n; i++) { for (int i = 0; i < numTables; ++i) {
PutUInt32(te[i].tag, ttf + 12, 16 * i, 1); PutUInt32(te[i].tag, ttf + 12, 16 * i, 1);
PutUInt32(CheckSum((sal_uInt32 *) te[i].data, te[i].length), ttf + 12, 16 * i + 4, 1); PutUInt32(CheckSum((sal_uInt32 *) te[i].data, te[i].length), ttf + 12, 16 * i + 4, 1);
PutUInt32(offset, ttf + 12, 16 * i + 8, 1); PutUInt32(offset, ttf + 12, 16 * i + 8, 1);
...@@ -311,7 +310,7 @@ int StreamToMemory(TrueTypeCreator *_this, sal_uInt8 **ptr, sal_uInt32 *length) ...@@ -311,7 +310,7 @@ int StreamToMemory(TrueTypeCreator *_this, sal_uInt8 **ptr, sal_uInt32 *length)
free(te); free(te);
p = (sal_uInt32 *) ttf; p = (sal_uInt32 *) ttf;
for (i = 0; i < (int)s / 4; i++) checkSumAdjustment += p[i]; for (int i = 0; i < (int)s / 4; ++i) checkSumAdjustment += p[i];
PutUInt32(0xB1B0AFBA - checkSumAdjustment, head, 8, 1); PutUInt32(0xB1B0AFBA - checkSumAdjustment, head, 8, 1);
*ptr = ttf; *ptr = ttf;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment