diff options
author | Klaus Schmidinger <vdr@tvdr.de> | 2011-02-25 15:25:42 +0100 |
---|---|---|
committer | Klaus Schmidinger <vdr@tvdr.de> | 2011-02-25 15:25:42 +0100 |
commit | d1ab9dbc5f0c35aa10ee0c67b9dc2eb6fd31dd13 (patch) | |
tree | 01b6346cf321f0c2569b2c12f43d931e5f6281a7 /themes.c | |
parent | e145ee45e2c2a112629814bcbba6f0e759f5132a (diff) | |
download | vdr-d1ab9dbc5f0c35aa10ee0c67b9dc2eb6fd31dd13.tar.gz vdr-d1ab9dbc5f0c35aa10ee0c67b9dc2eb6fd31dd13.tar.bz2 |
Now checking the result of all realloc() calls
Diffstat (limited to 'themes.c')
-rw-r--r-- | themes.c | 32 |
1 files changed, 25 insertions, 7 deletions
@@ -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++; } } |