Permalink
Browse files

Handle NULLs in SDKCall string return (Fixes #874) (#906)

`SDKCall` has existing semantics that a `-1` retval indicates null, so use that and writes an empty string to the buffer.

Consumers can tell the difference between `""` and `NULL` by checking if the return value is `0` or `-1`.
  • Loading branch information...
asherkin committed Oct 10, 2018
1 parent a659896 commit a1271ec3a86fa28907eb18d1fba707bfa75aecb4
Showing with 5 additions and 0 deletions.
  1. +5 −0 extensions/sdktools/vcaller.cpp
@@ -449,6 +449,11 @@ static cell_t SDKCall(IPluginContext *pContext, const cell_t *params)
cell_t *addr;
size_t written;
pContext->LocalToPhysAddr(params[retparam+1], &addr);
if (!(*(char **)vc->retbuf))
{
pContext->StringToLocalUTF8(params[retparam], *addr, "", &written);
return -1;
}
pContext->StringToLocalUTF8(params[retparam], *addr, *(char **)vc->retbuf, &written);
return (cell_t)written;
} else if (vc->retinfo->vtype == Valve_Vector

0 comments on commit a1271ec

Please sign in to comment.