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

Commit b159b2d

Browse files
committed
Updates after feedback #1
1 parent 7c1b79a commit b159b2d

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

engine/src/dispatch.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -739,14 +739,16 @@ IO_stat MCDispatch::doreadfile(const char *openpath, const char *inname, IO_hand
739739
stacks->setparent(this);
740740
stacks->setname_cstring("revScript");
741741
uint4 size = (uint4)MCS_fsize(stream);
742-
MCAutoStringRef t_script;
743-
/* UNCHECKED */ MCStringAppendNativeChar(&t_script, '\n');
744-
745-
if (IO_read(strdup(MCStringGetCString(*t_script)), size, stream) != IO_NORMAL
746-
|| !stacks->setscript(*t_script))
747-
{
748-
return IO_ERROR;
749-
}
742+
MCAutoPointer<char> script;
743+
script = new char[size + 2];
744+
(*script)[size] = '\n';
745+
(*script)[size + 1] = '\0';
746+
if (IO_read(*script, size, stream) != IO_NORMAL)
747+
return IO_ERROR;
748+
MCAutoStringRef t_script_str;
749+
/* UNCHECKED */ MCStringCreateWithCString(*script, &t_script_str);
750+
if (!stacks -> setscript(*t_script_str))
751+
return IO_ERROR;
750752
}
751753
else
752754
{

0 commit comments

Comments
 (0)