Skip to content

Commit

Permalink
Merge pull request #40 from alliedmodders/fix-invalid-string-index
Browse files Browse the repository at this point in the history
Fix FindStringIndex native not returning INVALID_STRING_INDEX when string not found (bug 6144, r=DS).
  • Loading branch information
psychonic committed Jun 19, 2014
2 parents 0f39825 + 291ef6f commit 58158ce
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion extensions/sdktools/vstringtable.cpp
Expand Up @@ -113,7 +113,15 @@ static cell_t FindStringIndex(IPluginContext *pContext, const cell_t *params)

pContext->LocalToString(params[2], &str);

return pTable->FindStringIndex(str);
int strindex = pTable->FindStringIndex(str);

// INVALID_STRING_INDEX is 65535 at time of writing, but already defined in sp inc files as -1
if (strindex == INVALID_STRING_INDEX)
{
return -1;
}

return strindex;
}

static cell_t ReadStringTable(IPluginContext *pContext, const cell_t *params)
Expand Down

0 comments on commit 58158ce

Please sign in to comment.