Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Theoretical problem

When resolving script imports, the code doesn't deals with empty string imports, and relies on nullptr :

This works because when reading script objects, empty strings (a single \0 character) are replaced by a nullptr :

But when writing a script object, we don't treat the nullptr case, so if you read a script object, and want to write it back to a file, this will break here :

A simple fix is to simply treat this case of nullptr when writing the script object :

if(imports[n]== nullptr){
    out->WriteArray("\0", 1, 1);
} else {
    out->WriteArray(imports[n], strlen(imports[n]) + 1, 1);

We have the empty strings in imports because currently the compiler picks up all imports and will just blank it (in Compiler/script/cs_compiler.cpp) mark the unused imports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.