Fix crash on Ubuntu when opening assembly files.
Ubuntu enables GCC's buffer overflow checks by default. In SAVEDptr union, the path was declared as 'char', even though MAX_PATH memory was actually allocated. The buffer overflow check mistakenly thought that the buffer size was only 1 and aborted the program whenever it tried to read a path from a file.
This commit is contained in:
parent
e587d0ebee
commit
8996833989
|
@ -204,7 +204,7 @@ const SolveSpace::SaveTable SolveSpace::SAVED[] = {
|
||||||
union SAVEDptr {
|
union SAVEDptr {
|
||||||
IdList<EntityMap,EntityId> M;
|
IdList<EntityMap,EntityId> M;
|
||||||
NameStr N;
|
NameStr N;
|
||||||
char P;
|
char P[MAX_PATH];
|
||||||
bool b;
|
bool b;
|
||||||
RgbColor c;
|
RgbColor c;
|
||||||
int d;
|
int d;
|
||||||
|
@ -228,7 +228,7 @@ void SolveSpace::SaveUsingTable(int type) {
|
||||||
fprintf(fh, "%s=", SAVED[i].desc);
|
fprintf(fh, "%s=", SAVED[i].desc);
|
||||||
switch(fmt) {
|
switch(fmt) {
|
||||||
case 'N': fprintf(fh, "%s", p->N.str); break;
|
case 'N': fprintf(fh, "%s", p->N.str); break;
|
||||||
case 'P': fprintf(fh, "%s", &(p->P)); break;
|
case 'P': fprintf(fh, "%s", p->P); break;
|
||||||
case 'b': fprintf(fh, "%d", p->b ? 1 : 0); break;
|
case 'b': fprintf(fh, "%d", p->b ? 1 : 0); break;
|
||||||
case 'c': fprintf(fh, "%08x", p->c.ToPackedInt()); break;
|
case 'c': fprintf(fh, "%08x", p->c.ToPackedInt()); break;
|
||||||
case 'd': fprintf(fh, "%d", p->d); break;
|
case 'd': fprintf(fh, "%d", p->d); break;
|
||||||
|
@ -385,7 +385,7 @@ void SolveSpace::LoadUsingTable(char *key, char *val) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'P':
|
case 'P':
|
||||||
if(strlen(val)+1 < MAX_PATH) strcpy(&(p->P), val);
|
if(strlen(val)+1 < MAX_PATH) strcpy(p->P, val);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'M': {
|
case 'M': {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user