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.
pull/3/head
Petteri Aimonen 2014-12-29 22:16:21 +02:00
parent e587d0ebee
commit 8996833989
1 changed files with 3 additions and 3 deletions

View File

@ -204,7 +204,7 @@ const SolveSpace::SaveTable SolveSpace::SAVED[] = {
union SAVEDptr {
IdList<EntityMap,EntityId> M;
NameStr N;
char P;
char P[MAX_PATH];
bool b;
RgbColor c;
int d;
@ -228,7 +228,7 @@ void SolveSpace::SaveUsingTable(int type) {
fprintf(fh, "%s=", SAVED[i].desc);
switch(fmt) {
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 'c': fprintf(fh, "%08x", p->c.ToPackedInt()); break;
case 'd': fprintf(fh, "%d", p->d); break;
@ -385,7 +385,7 @@ void SolveSpace::LoadUsingTable(char *key, char *val) {
break;
case 'P':
if(strlen(val)+1 < MAX_PATH) strcpy(&(p->P), val);
if(strlen(val)+1 < MAX_PATH) strcpy(p->P, val);
break;
case 'M': {