[beryl-commits] compiz mirror: Changes to 'master' (6d92eff1efd83a1bb6168e3d8001b60d6d52bac7)
compiz at server.beryl-project.org
compiz at server.beryl-project.org
Fri Jun 22 01:46:05 CEST 2007
New commits:
commit 6d92eff1efd83a1bb6168e3d8001b60d6d52bac7
Author: Roland Bar <roland at verifysoft.de>
Date: Fri Jun 22 00:40:27 2007 +0100
Fix memory leaks and remove dead code
plugins/ini.c | 25 +++++++++++++++++++------
1 files changed, 19 insertions(+), 6 deletions(-)
Modified: compiz/plugins/ini.c
===================================================================
--- compiz/plugins/ini.c
+++ compiz/plugins/ini.c
@@ -197,10 +197,11 @@ iniGetFileDataFromFilename (CompDisplay *d,
if (!newFd)
return NULL;
- /* fd now contains 'prev' or NULL */
- if (fd)
+ /* fd is NULL here, see condition "fd" in first for-loop */
+ /* if (fd)
fd->next = newFd;
else
+ */
id->fileData = newFd;
newFd->prev = fd;
@@ -209,10 +210,14 @@ iniGetFileDataFromFilename (CompDisplay *d,
newFd->filename = strdup (filename);
pluginStr = calloc (1, sizeof (char) * pluginSep + 2);
- screenStr = calloc (1, sizeof (char) * (screenSep - pluginSep));
+ if (!pluginStr)
+ return NULL;
- if (!pluginStr || !screenStr)
+ screenStr = calloc (1, sizeof (char) * (screenSep - pluginSep));
+ if (!screenStr) {
+ free(pluginStr);
return NULL;
+ }
strncpy (pluginStr, filename, pluginSep + 1);
strncpy (screenStr, &filename[pluginSep+2], (screenSep - pluginSep) - 1);
@@ -258,7 +263,11 @@ iniOptionValueToString (CompOptionValue *value, CompOptionType type)
snprintf (tmp, 10, "%s", colorToString (value->c));
break;
case CompOptionTypeMatch:
- snprintf (tmp, MAX_OPTION_LENGTH, "%s", matchToString (&value->match));
+ {
+ char *s = matchToString (&value->match);
+ snprintf (tmp, MAX_OPTION_LENGTH, "%s", s);
+ free(s);
+ }
break;
default:
break;
@@ -314,6 +323,7 @@ iniGetFilename (CompDisplay *d,
compLogMessage (d, "ini", CompLogLevelWarn,
"Invalid screen number passed " \
"to iniGetFilename %d", screen);
+ free(screenStr);
return FALSE;
}
snprintf (screenStr, 12, "screen%d", screen);
@@ -999,8 +1009,11 @@ iniSaveOptions (CompDisplay *d,
char *itemVal;
strVal = malloc (sizeof(char) * stringLen);
- if (!strVal)
+ if (!strVal) {
+ fclose(optionFile);
+ free(fullPath);
return FALSE;
+ }
strcpy (strVal, "");
firstInList = TRUE;
More information about the commits
mailing list