Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit b215f78

Browse files
[[ LinuxServer ]] Fixes parsing of the script files, and overeleasing of the script
1 parent e9eeb1b commit b215f78

3 files changed

Lines changed: 13 additions & 8 deletions

File tree

engine/src/exec-server.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ void MCServerExecInclude(MCExecContext& ctxt, MCStringRef p_filename, bool p_is_
180180

181181
void MCServerExecEcho(MCExecContext& ctxt, MCStringRef p_data)
182182
{
183-
if (!MCS_put(ctxt, kMCSPutBinaryOutput, p_data))
183+
if (!MCS_put(ctxt, kMCSPutOutput, p_data))
184184
MCexitall = True;
185185
}
186186

engine/src/scriptpt.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,9 +412,9 @@ codepoint_t MCScriptPoint::getcodepointatindex(uindex_t p_index)
412412
{
413413
uindex_t t_index = 0;
414414
while (p_index--)
415-
MCUnicodeCodepointAdvance((curptr + t_index), endptr - curptr - t_index, t_index);
415+
MCUnicodeCodepointAdvance(curptr, endptr - curptr - t_index, t_index);
416416

417-
return MCUnicodeCodepointAdvance((curptr + t_index), endptr - curptr - t_index, t_index);
417+
return MCUnicodeCodepointAdvance(curptr, endptr - curptr - t_index, t_index);
418418
}
419419

420420
void MCScriptPoint::setcurptr(const unichar_t *ptr)

engine/src/srvscript.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,16 @@ MCServerScript::~MCServerScript(void)
5858
File *t_file;
5959
t_file = m_files;
6060
m_files = m_files -> next;
61-
62-
if (t_file -> handle != NULL)
63-
t_file -> handle -> Close();
64-
delete t_file -> filename;
65-
delete t_file -> script;
61+
62+
// Closing a MCMemoryMappedFileHandle calls unmap()
63+
// and thus deallocates the memory mapped - which is what's stored in t_file -> script
64+
if (t_file -> handle != NULL)
65+
t_file -> handle -> Close();
66+
else
67+
delete t_file -> script;
68+
69+
delete t_file -> filename;
70+
6671
delete t_file;
6772
}
6873

0 commit comments

Comments
 (0)