summaryrefslogtreecommitdiff
path: root/sot
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2015-02-05 23:30:22 +0100
committerMichael Stahl <mstahl@redhat.com>2015-02-05 23:33:35 +0100
commit004304eb2fd1703d22dec0abf0170bb2ce493d0c (patch)
tree2cc68735fa3eb215f043fa6f175f3fcb0e03f88f /sot
parentb0ef5cf258f3a84054c052f0a09a208dbc17fdf3 (diff)
try to avoid overflows in some compare functions
Change-Id: I6144d7d6527dc401b7f1b577d1a227361e39e7bb
Diffstat (limited to 'sot')
-rw-r--r--sot/source/sdstor/stgelem.cxx11
-rw-r--r--sot/source/sdstor/stgelem.hxx2
2 files changed, 6 insertions, 7 deletions
diff --git a/sot/source/sdstor/stgelem.cxx b/sot/source/sdstor/stgelem.cxx
index 4b29e10c7075..3e1dc9543d4a 100644
--- a/sot/source/sdstor/stgelem.cxx
+++ b/sot/source/sdstor/stgelem.cxx
@@ -350,13 +350,12 @@ void StgEntry::GetName( OUString& rName ) const
// Compare two entries. Do this case-insensitive.
-short StgEntry::Compare( const StgEntry& r ) const
+sal_Int32 StgEntry::Compare( const StgEntry& r ) const
{
- sal_Int32 nRes = r.nNameLen - nNameLen;
- if( !nRes )
- nRes = r.aName.compareTo( aName );
-
- return (short)nRes;
+ if (r.nNameLen != nNameLen)
+ return r.nNameLen > nNameLen ? 1 : -1;
+ else
+ return r.aName.compareTo(aName);
}
// These load/store operations are a bit more complicated,
diff --git a/sot/source/sdstor/stgelem.hxx b/sot/source/sdstor/stgelem.hxx
index b4b386cdebda..c36b5b48b4e7 100644
--- a/sot/source/sdstor/stgelem.hxx
+++ b/sot/source/sdstor/stgelem.hxx
@@ -128,7 +128,7 @@ public:
bool SetName( const OUString& ); // store a name (ASCII, up to 32 chars)
void GetName( OUString& rName ) const;
// fill in the name
- short Compare( const StgEntry& ) const; // compare two entries
+ sal_Int32 Compare( const StgEntry& ) const; // compare two entries
bool Load( const void* pBuffer, sal_uInt32 nBufSize );
void Store( void* );
StgEntryType GetType() const { return (StgEntryType) cType; }