diff --git a/src/runtime/o_func.c b/src/runtime/o_func.c index 3dc18b1..b739b7a 100644 --- a/src/runtime/o_func.c +++ b/src/runtime/o_func.c @@ -46,8 +46,16 @@ Object *Object_FromNojaFunction(Runtime *runtime, Executable *exe, int index, He if(func == NULL) return NULL; + Executable *exe_copy = Executable_Copy(exe); + + if(exe_copy == NULL) + { + Error_Report(error, 1, "Failed to copy executable"); + return NULL; + } + func->runtime = runtime; - func->exe = exe; + func->exe = exe_copy; func->index = index; return (Object*) func; } \ No newline at end of file diff --git a/src/utils/source.c b/src/utils/source.c index f6bbf0b..49552e5 100644 --- a/src/utils/source.c +++ b/src/utils/source.c @@ -155,6 +155,9 @@ Source *Source_FromString(const char *name, const char *body, int size, Error *e if(name) strcpy(s->name, name); + else + s->name = NULL; + strncpy(s->body, body, size); return s; } \ No newline at end of file