Fixed memory leak.
authorArmin Novak <armin.novak@gmail.com>
Sun, 16 Nov 2014 21:47:23 +0000 (22:47 +0100)
committerArmin Novak <armin.novak@gmail.com>
Sun, 16 Nov 2014 21:47:23 +0000 (22:47 +0100)
winpr/libwinpr/environment/environment.c

index fd4a0bb..e006f43 100644 (file)
@@ -345,7 +345,10 @@ LPCH MergeEnvironmentStrings(PCSTR original, PCSTR merge)
        lpszEnvironmentBlock = (LPCH) malloc(cchEnvironmentBlock * sizeof(CHAR));
 
        if (!lpszEnvironmentBlock)
+       {
+               free (mergeStrings);
                return NULL;
+       }
 
        envp  = original;
 
@@ -361,8 +364,8 @@ LPCH MergeEnvironmentStrings(PCSTR original, PCSTR merge)
 
                        if (!tmp)
                        {
-                               if (lpszEnvironmentBlock)
-                                       free (lpszEnvironmentBlock);    
+                               free (lpszEnvironmentBlock);
+                               free (mergeStrings);
                                return NULL;
                        }
                        lpszEnvironmentBlock = tmp;
@@ -404,6 +407,7 @@ LPCH MergeEnvironmentStrings(PCSTR original, PCSTR merge)
                                                {
                                                        if (lpszEnvironmentBlock)
                                                                free(lpszEnvironmentBlock);
+                                                       free (mergeStrings);
                                                        return NULL;
                                                }
                                                lpszEnvironmentBlock = tmp;
@@ -447,6 +451,7 @@ LPCH MergeEnvironmentStrings(PCSTR original, PCSTR merge)
                        {
                                if (lpszEnvironmentBlock)
                                        free(lpszEnvironmentBlock);
+                               free (mergeStrings);
                                return NULL;
                        }