mirror of
				https://github.com/vdr-projects/vdr.git
				synced 2025-03-01 10:50:46 +00:00 
			
		
		
		
	Now checking the result of all realloc() calls
This commit is contained in:
		
							
								
								
									
										32
									
								
								themes.c
									
									
									
									
									
								
							
							
						
						
									
										32
									
								
								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++; | ||||
|                     } | ||||
|                  } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user