diff options
author | Klaus Schmidinger <vdr@tvdr.de> | 2007-02-17 16:10:46 +0100 |
---|---|---|
committer | Klaus Schmidinger <vdr@tvdr.de> | 2007-02-17 16:10:46 +0100 |
commit | cc385f5292669738e105a689ae3df700c87c4a78 (patch) | |
tree | 85b5df494c784de35dfe36ec3c6f495dd1f8676a /osd.c | |
parent | f3bc8d1988c265c4bf99c27826c3a9e985bfa31d (diff) | |
download | vdr-cc385f5292669738e105a689ae3df700c87c4a78.tar.gz vdr-cc385f5292669738e105a689ae3df700c87c4a78.tar.bz2 |
Fixed a possible crash when loading an invalid XPM file
Diffstat (limited to 'osd.c')
-rw-r--r-- | osd.c | 22 |
1 files changed, 15 insertions, 7 deletions
@@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: osd.c 1.67 2006/02/26 14:31:31 kls Exp $ + * $Id: osd.c 1.68 2007/02/17 16:05:52 kls Exp $ */ #include "osd.h" @@ -218,14 +218,17 @@ bool cBitmap::LoadXpm(const char *FileName) int w, h, n, c; if (4 != sscanf(s, "%d %d %d %d", &w, &h, &n, &c)) { esyslog("ERROR: faulty 'values' line in XPM file '%s'", FileName); + isXpm = false; break; } lines = h + n + 1; Xpm = MALLOC(char *, lines); + memset(Xpm, 0, lines * sizeof(char*)); } char *q = strchr(s, '"'); if (!q) { esyslog("ERROR: missing quotes in XPM file '%s'", FileName); + isXpm = false; break; } *q = 0; @@ -233,16 +236,21 @@ bool cBitmap::LoadXpm(const char *FileName) Xpm[index++] = strdup(s); else { esyslog("ERROR: too many lines in XPM file '%s'", FileName); + isXpm = false; break; } } } - if (index == lines) - Result = SetXpm(Xpm); - else - esyslog("ERROR: too few lines in XPM file '%s'", FileName); - for (int i = 0; i < index; i++) - free(Xpm[i]); + if (isXpm) { + if (index == lines) + Result = SetXpm(Xpm); + else + esyslog("ERROR: too few lines in XPM file '%s'", FileName); + } + if (Xpm) { + for (int i = 0; i < index; i++) + free(Xpm[i]); + } free(Xpm); fclose(f); } |