mirror of
https://github.com/CPunch/Cosmo.git
synced 2024-11-22 07:20:05 +00:00
fixed segfault on parser objection
This commit is contained in:
parent
2e1b745624
commit
8e71cab642
@ -23,6 +23,9 @@ CObj *cosmoO_allocateObject(CState *state, size_t sz, CObjType type) {
|
|||||||
|
|
||||||
obj->next = state->objects;
|
obj->next = state->objects;
|
||||||
state->objects = obj;
|
state->objects = obj;
|
||||||
|
#ifdef GC_DEBUG
|
||||||
|
printf("allocated %p with OBJ_TYPE %d\n", obj, type);
|
||||||
|
#endif
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -995,14 +995,13 @@ CObjFunction* cosmoP_compileString(CState *state, const char *source) {
|
|||||||
|
|
||||||
popLocals(&parser, -1); // needed to close over the values
|
popLocals(&parser, -1); // needed to close over the values
|
||||||
|
|
||||||
if (parser.hadError) { // free the function too
|
if (parser.hadError) { // we don't free the function, the state already has a reference to it in it's linked list of objects!
|
||||||
cosmoO_freeObject(state, (CObj*)parser.compiler->function);
|
|
||||||
endCompiler(&parser, 0);
|
endCompiler(&parser, 0);
|
||||||
freeParseState(&parser);
|
freeParseState(&parser);
|
||||||
|
|
||||||
// the VM still expects a result on the stack TODO: push the error string to the stack
|
// the VM still expects a result on the stack TODO: push the error string to the stack
|
||||||
cosmoV_pushValue(state, cosmoV_newNil());
|
cosmoV_pushValue(state, cosmoV_newNil());
|
||||||
cosmoM_unfreezeGC(state);
|
cosmoM_unfreezeGC(state);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1012,6 +1011,6 @@ CObjFunction* cosmoP_compileString(CState *state, const char *source) {
|
|||||||
|
|
||||||
endCompiler(&parser, 0);
|
endCompiler(&parser, 0);
|
||||||
freeParseState(&parser);
|
freeParseState(&parser);
|
||||||
cosmoM_unfreezeGC(state);
|
cosmoM_unfreezeGC(state);
|
||||||
return resFunc;
|
return resFunc;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user