diff options
author | Eugene Sandulenko | 2019-10-25 00:16:24 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2019-10-25 00:16:37 +0200 |
commit | 49b83925a00aed9f4283c42013260d4e3bbb9a5a (patch) | |
tree | 6bce54899868208964362156f9750e1f242b3282 /engines/scumm | |
parent | 9f71bcab74ae2075cb290342470d54581b87b461 (diff) | |
download | scummvm-rg350-49b83925a00aed9f4283c42013260d4e3bbb9a5a.tar.gz scummvm-rg350-49b83925a00aed9f4283c42013260d4e3bbb9a5a.tar.bz2 scummvm-rg350-49b83925a00aed9f4283c42013260d4e3bbb9a5a.zip |
SCUMM HE: Fix double free
Diffstat (limited to 'engines/scumm')
-rw-r--r-- | engines/scumm/he/moonbase/net_main.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/engines/scumm/he/moonbase/net_main.cpp b/engines/scumm/he/moonbase/net_main.cpp index 0c405025cf..4b3fce498f 100644 --- a/engines/scumm/he/moonbase/net_main.cpp +++ b/engines/scumm/he/moonbase/net_main.cpp @@ -76,8 +76,9 @@ int Net::addUser(char *shortName, char *longName) { new Common::Callback<Net, Common::JSONValue *>(this, &Net::addUserCallback), new Common::Callback<Net, Networking::ErrorResponse>(this, &Net::addUserErrorCallback)); - snprintf((char *)_tmpbuffer, MAX_PACKET_SIZE, "{\"shortname\":\"%s\",\"longname\":\"%s\",\"sessionid\":%d}", shortName, longName, _sessionid); - rq.setPostData(_tmpbuffer, strlen((char *)_tmpbuffer)); + char *buf = (char *)malloc(MAX_PACKET_SIZE); + snprintf(buf, MAX_PACKET_SIZE, "{\"shortname\":\"%s\",\"longname\":\"%s\",\"sessionid\":%d}", shortName, longName, _sessionid); + rq.setPostData((byte *)buf, strlen(buf)); rq.setContentType("application/json"); rq.start(); @@ -129,8 +130,9 @@ int Net::createSession(char *name) { new Common::Callback<Net, Common::JSONValue *>(this, &Net::createSessionCallback), new Common::Callback<Net, Networking::ErrorResponse>(this, &Net::createSessionErrorCallback)); - snprintf((char *)_tmpbuffer, MAX_PACKET_SIZE, "{\"name\":\"%s\"}", name); - rq.setPostData(_tmpbuffer, strlen((char *)_tmpbuffer)); + char *buf = (char *)malloc(MAX_PACKET_SIZE); + snprintf(buf, MAX_PACKET_SIZE, "{\"name\":\"%s\"}", name); + rq.setPostData((byte *)buf, strlen(buf)); rq.setContentType("application/json"); rq.start(); |