Merge pull request #4 from VoiDeD/push-string

Push strings instead of arrays to not have to deal with odd cell size calculations.
This commit is contained in:
KyleSanderson
2014-04-05 13:24:57 -06:00
2 changed files with 7 additions and 6 deletions
+3 -1
View File
@@ -84,7 +84,9 @@ EBeginAuthSessionResult SteamWorksGSHooks::BeginAuthSession(const void *pAuthTic
{
if (this->pOBAS->GetFunctionCount() != 0)
{
this->pOBAS->PushArray(pAuthTicket, cbAuthTicket);
char *pszAuthTicket = reinterpret_cast<char *>(const_cast<void *>(pAuthTicket));
this->pOBAS->PushStringEx(pszAuthTicket, cbAuthTicket, SM_PARAM_STRING_BINARY | SM_PARAM_STRING_COPY, 0);
this->pOBAS->PushCell(cbAuthTicket);
this->pOBAS->PushCell(steamID.GetAccountID());
this->pOBAS->Execute(NULL);
+4 -5
View File
@@ -588,8 +588,7 @@ static cell_t sm_GetHTTPResponseBodyCallback(IPluginContext *pContext, const cel
return 0;
}
size_t celllen = ((size / sizeof(cell_t)) + 1);
cell_t *pBuffer = new cell_t[celllen+1];
char *pBuffer = new char[size+1];
if (pHTTP->GetHTTPResponseBodyData(pRequest->request, reinterpret_cast<uint8_t *>(pBuffer), size) == false)
{
@@ -597,10 +596,10 @@ static cell_t sm_GetHTTPResponseBodyCallback(IPluginContext *pContext, const cel
return 0;
}
pBuffer[celllen] = '\0'; /* Incase users do something bad; we want to protect userspace; kind of. */
pFunction->PushArray(pBuffer, celllen); /* Strings do a copy... it's really bad :( */
pBuffer[size] = '\0'; /* Incase users do something bad; we want to protect userspace; kind of. */
pFunction->PushStringEx(pBuffer, size, SM_PARAM_STRING_BINARY | SM_PARAM_STRING_COPY, 0);
pFunction->PushCell(params[3]);
pFunction->PushCell(celllen);
pFunction->PushCell(size);
pFunction->Execute(NULL);
delete [] pBuffer;