Skip to content

Commit 9ae0a91

Browse files
committed
Fixed a bunch of quoting errors + fixed a potential crash with symbol files
1 parent 8eee06a commit 9ae0a91

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/asar/interface-cli.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -465,9 +465,17 @@ int main(int argc, char * argv[])
465465
if (!symfilename) symfilename = get_base_name(romname)+".sym";
466466
string contents = create_symbols_file(symbols, romCrc);
467467
FILE * symfile = fopen(symfilename, "wt");
468-
fputs(contents, symfile);
469-
fclose(symfile);
470-
468+
if (!symfile)
469+
{
470+
puts(STR"Failed to create symbols file: \"" + symfilename + "\".");
471+
pause(err);
472+
return 1;
473+
}
474+
else
475+
{
476+
fputs(contents, symfile);
477+
fclose(symfile);
478+
}
471479
}
472480
reseteverything();
473481
}

src/asar/libstr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ bool readfile(const char * fname, const char * basepath, char ** data, int * len
156156
return true;
157157
}
158158

159-
#define dequote(var, next, error) if (var=='"') do { next; while (var!='"') { if (!var) error; next; } next; } while(0); else if (var=='\'') do { next; if (!var) error; next; if(var != '\'') error; next; } while(0)
159+
#define dequote(var, next, error) if (var=='"') do { next; while (var!='"' && var != '\0') { if (!var) error; next; } if (var == '\0') error; next; } while(0); else if (var=='\'') do { next; if (!var) error; /* ''' special case hack */ if (var=='\'') { next; if (var!='\'') error; next; } else { next; while (var!='\'' && var != '\0') { if (!var) error; next; } if (var == '\0') error; next; } } while(0)
160160
#define skippar(var, next, error) dequote(var, next, error); else if (var=='(') { int par=1; next; while (par) { dequote(var, next, error); else { \
161161
if (var=='(') par++; if (var==')') par--; if (!var) error; next; } } } else if (var==')') error
162162

0 commit comments

Comments
 (0)