xpm segv fix

SVN revision: 14832
This commit is contained in:
Carsten Haitzler 2005-05-18 05:27:43 +00:00
parent 6c7da57569
commit 0bcb0033ed
1 changed files with 14 additions and 2 deletions

View File

@ -108,7 +108,7 @@ load(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity,
FILE *f; FILE *f;
int pc, c, i, j, k, w, h, ncolors, cpp, comment, transp, int pc, c, i, j, k, w, h, ncolors, cpp, comment, transp,
quote, context, len, done, r, g, b; quote, context, len, done, r, g, b, backslash;
char *line, s[256], tok[128], col[256]; char *line, s[256], tok[128], col[256];
int lsz = 256; int lsz = 256;
struct _cmap { struct _cmap {
@ -163,6 +163,7 @@ load(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity,
pixels = 0; pixels = 0;
count = 0; count = 0;
line = malloc(lsz); line = malloc(lsz);
backslash = 0;
memset(lookup, 0, sizeof(lookup)); memset(lookup, 0, sizeof(lookup));
while (!done) while (!done)
{ {
@ -645,7 +646,18 @@ load(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity,
c = 32; c = 32;
else if (c > 127) else if (c > 127)
c = 127; c = 127;
line[i++] = c; if ( c=='\\' ) {
if ( ++backslash<2 ) {
line[i++] = c;
}
else {
backslash = 0;
}
}
else {
backslash = 0;
line[i++] = c;
}
} }
if (i >= lsz) if (i >= lsz)
{ {