From 49b83925a00aed9f4283c42013260d4e3bbb9a5a Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Fri, 25 Oct 2019 00:16:24 +0200 Subject: SCUMM HE: Fix double free --- engines/scumm/he/moonbase/net_main.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'engines/scumm/he/moonbase/net_main.cpp') 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(this, &Net::addUserCallback), new Common::Callback(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(this, &Net::createSessionCallback), new Common::Callback(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(); -- cgit v1.2.3