summaryrefslogtreecommitdiffstats
path: root/qtools/qgdict.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'qtools/qgdict.cpp')
-rw-r--r--qtools/qgdict.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/qtools/qgdict.cpp b/qtools/qgdict.cpp
index e9306bb..e55d059 100644
--- a/qtools/qgdict.cpp
+++ b/qtools/qgdict.cpp
@@ -92,16 +92,17 @@ int QGDict::hashKeyString( const QString &key )
int i;
register uint h=0;
uint g;
+ int len = key.length();
const QChar *p = key.unicode();
if ( cases ) { // case sensitive
- for ( i=0; i<(int)key.length(); i++ ) {
+ for ( i=0; i<len; i++ ) {
h = (h<<4) + p[i].cell();
if ( (g = h & 0xf0000000) )
h ^= g >> 24;
h &= ~g;
}
} else { // case insensitive
- for ( i=0; i<(int)key.length(); i++ ) {
+ for ( i=0; i<len; i++ ) {
h = (h<<4) + p[i].lower().cell();
if ( (g = h & 0xf0000000) )
h ^= g >> 24;
@@ -123,7 +124,10 @@ int QGDict::hashKeyAscii( const char *key )
{
#if defined(CHECK_NULL)
if ( key == 0 )
+ {
qWarning( "QGDict::hashAsciiKey: Invalid null key" );
+ return 0;
+ }
#endif
register const char *k = key;
register uint h=0;