summaryrefslogtreecommitdiff
path: root/epg.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 /epg.c
parente145ee45e2c2a112629814bcbba6f0e759f5132a (diff)
downloadvdr-d1ab9dbc5f0c35aa10ee0c67b9dc2eb6fd31dd13.tar.gz
vdr-d1ab9dbc5f0c35aa10ee0c67b9dc2eb6fd31dd13.tar.bz2
Now checking the result of all realloc() calls
Diffstat (limited to 'epg.c')
-rw-r--r--epg.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/epg.c b/epg.c
index 18d91fc7..c2d1783d 100644
--- a/epg.c
+++ b/epg.c
@@ -7,7 +7,7 @@
* Original version (as used in VDR before 1.3.0) written by
* Robert Schneider <Robert.Schneider@web.de> and Rolf Hakenes <hakenes@hippomi.de>.
*
- * $Id: epg.c 2.6 2010/02/28 14:24:55 kls Exp $
+ * $Id: epg.c 2.7 2011/02/25 15:16:05 kls Exp $
*/
#include "epg.h"
@@ -56,25 +56,34 @@ cComponents::~cComponents(void)
free(components);
}
-void cComponents::Realloc(int Index)
+bool cComponents::Realloc(int Index)
{
if (Index >= numComponents) {
- int n = numComponents;
- numComponents = Index + 1;
- components = (tComponent *)realloc(components, numComponents * sizeof(tComponent));
- memset(&components[n], 0, sizeof(tComponent) * (numComponents - n));
+ Index++;
+ if (tComponent *NewBuffer = (tComponent *)realloc(components, Index * sizeof(tComponent))) {
+ int n = numComponents;
+ numComponents = Index;
+ components = NewBuffer;
+ memset(&components[n], 0, sizeof(tComponent) * (numComponents - n));
+ }
+ else {
+ esyslog("ERROR: out of memory");
+ return false;
+ }
}
+ return true;
}
void cComponents::SetComponent(int Index, const char *s)
{
- Realloc(Index);
- components[Index].FromString(s);
+ if (Realloc(Index))
+ components[Index].FromString(s);
}
void cComponents::SetComponent(int Index, uchar Stream, uchar Type, const char *Language, const char *Description)
{
- Realloc(Index);
+ if (!Realloc(Index))
+ return;
tComponent *p = &components[Index];
p->stream = Stream;
p->type = Type;