summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2015-02-19 16:55:04 +0100
committerMichael Stahl <mstahl@redhat.com>2015-02-25 23:58:04 +0100
commitb825167228b016e77435246fb4bf1e2bd184311f (patch)
treec8950278c5efd0c8650648536683986ca1b204bf
parent250ef02bd80e15bdc7fe86ba149b8c838b363114 (diff)
vcl: these compare functions use subtraction and could overflow
Change-Id: I84c7a4cde694395fa70c60edffd63fb45ffcb3a8
-rw-r--r--vcl/source/fontsubset/ttcr.cxx12
1 files changed, 7 insertions, 5 deletions
diff --git a/vcl/source/fontsubset/ttcr.cxx b/vcl/source/fontsubset/ttcr.cxx
index 25c66d1e3ba2..5e54061ea6bb 100644
--- a/vcl/source/fontsubset/ttcr.cxx
+++ b/vcl/source/fontsubset/ttcr.cxx
@@ -148,7 +148,9 @@ _inline void PutUInt32(sal_uInt32 val, sal_uInt8 *ptr, sal_uInt32 offset, int bi
static int TableEntryCompareF(const void *l, const void *r)
{
- return ((const TableEntry *) l)->tag - ((const TableEntry *) r)->tag;
+ sal_uInt32 const ltag(static_cast<TableEntry const*>(l)->tag);
+ sal_uInt32 const rtag(static_cast<TableEntry const*>(r)->tag);
+ return (ltag == rtag) ? 0 : (ltag < rtag) ? -1 : 1;
}
static int NameRecordCompareF(const void *l, const void *r)
@@ -157,13 +159,13 @@ static int NameRecordCompareF(const void *l, const void *r)
NameRecord *rr = (NameRecord *) r;
if (ll->platformID != rr->platformID) {
- return ll->platformID - rr->platformID;
+ return (ll->platformID < rr->platformID) ? -1 : 1;
} else if (ll->encodingID != rr->encodingID) {
- return ll->encodingID - rr->encodingID;
+ return (ll->encodingID < rr->encodingID) ? -1 : 1;
} else if (ll->languageID != rr->languageID) {
- return ll->languageID - rr->languageID;
+ return (ll->languageID < rr->languageID) ? -1 : 1;
} else if (ll->nameID != rr->nameID) {
- return ll->nameID - rr->nameID;
+ return (ll->nameID < rr->nameID) ? -1 : 1;
}
return 0;
}