In general it is a bad idea to compare memory. We should compare strings and check its length. Fixes #34.

This commit is contained in:
Rafal Kupiec 2018-08-02 17:42:19 +02:00
parent 19f8cf2599
commit e0b939d9a2
Signed by: belliash
GPG Key ID: 4E829243E0CFE6B4
1 changed files with 1 additions and 1 deletions

View File

@ -639,7 +639,7 @@ static sxu32 KeywordCode(const char *z, int n) {
return PH7_TK_ID;
} else {
for(ph7_token *pToken = pTokenLookup; pToken != pTokenLookup + sizeof(pTokenLookup) / sizeof(pTokenLookup[0]); pToken++) {
if(SyMemcmp(pToken->token, z, n) == 0) {
if(n == SyStrlen(pToken->token) && SyStrncmp(pToken->token, z, n) == 0) {
return pToken->value;
}
}