summaryrefslogtreecommitdiff
path: root/themes.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2011-02-25 15:25:42 +0100
committerKlaus Schmidinger <vdr@tvdr.de>2011-02-25 15:25:42 +0100
commitd1ab9dbc5f0c35aa10ee0c67b9dc2eb6fd31dd13 (patch)
tree01b6346cf321f0c2569b2c12f43d931e5f6281a7 /themes.c
parente145ee45e2c2a112629814bcbba6f0e759f5132a (diff)
downloadvdr-d1ab9dbc5f0c35aa10ee0c67b9dc2eb6fd31dd13.tar.gz
vdr-d1ab9dbc5f0c35aa10ee0c67b9dc2eb6fd31dd13.tar.bz2
Now checking the result of all realloc() calls
Diffstat (limited to 'themes.c')
-rw-r--r--themes.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/themes.c b/themes.c
index e6ee87e3..034ec0b9 100644
--- a/themes.c
+++ b/themes.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: themes.c 1.8 2008/02/10 16:25:00 kls Exp $
+ * $Id: themes.c 2.1 2011/02/25 14:45:18 kls Exp $
*/
#include "themes.h"
@@ -248,12 +248,30 @@ bool cThemes::Load(const char *SkinName)
cString FileName = AddDirectory(themesDirectory, e->d_name);
cTheme Theme;
if (Theme.Load(*FileName, true)) {
- names = (char **)realloc(names, (numThemes + 1) * sizeof(char *));
- names[numThemes] = strdup(Theme.Name());
- fileNames = (char **)realloc(fileNames, (numThemes + 1) * sizeof(char *));
- fileNames[numThemes] = strdup(*FileName);
- descriptions = (char **)realloc(descriptions, (numThemes + 1) * sizeof(char *));
- descriptions[numThemes] = strdup(Theme.Description());
+ if (char **NewBuffer = (char **)realloc(names, (numThemes + 1) * sizeof(char *))) {
+ names = NewBuffer;
+ names[numThemes] = strdup(Theme.Name());
+ }
+ else {
+ esyslog("ERROR: out of memory");
+ break;
+ }
+ if (char **NewBuffer = (char **)realloc(fileNames, (numThemes + 1) * sizeof(char *))) {
+ fileNames = NewBuffer;
+ fileNames[numThemes] = strdup(*FileName);
+ }
+ else {
+ esyslog("ERROR: out of memory");
+ break;
+ }
+ if (char **NewBuffer = (char **)realloc(descriptions, (numThemes + 1) * sizeof(char *))) {
+ descriptions = NewBuffer;
+ descriptions[numThemes] = strdup(Theme.Description());
+ }
+ else {
+ esyslog("ERROR: out of memory");
+ break;
+ }
numThemes++;
}
}