Skip to content

Commit 448e1dc

Browse files
Fix integer overflow in hash function. (#454)
1 parent dc081ee commit 448e1dc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ov/src/OVLexicon.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ static OVstatus OVLexicon_CheckStorage(OVLexicon * uk, ov_word entry_size,
9999
static ov_word _GetCStringHash(ov_uchar8 * str)
100100
{
101101
const ov_uchar8 *p = str;
102-
ov_word x;
102+
ov_size x;
103103
ov_size len = 0;
104104
ov_uchar8 c;
105105

@@ -109,7 +109,7 @@ static ov_word _GetCStringHash(ov_uchar8 * str)
109109
len++;
110110
}
111111
x ^= len;
112-
return x;
112+
return static_cast<ov_word>(x);
113113
}
114114

115115
OVstatus OVLexicon_Pack(OVLexicon * uk)

0 commit comments

Comments
 (0)