Fixed memory leak.
authorArmin Novak <armin.novak@gmail.com>
Sun, 16 Nov 2014 16:07:48 +0000 (17:07 +0100)
committerArmin Novak <armin.novak@gmail.com>
Sun, 16 Nov 2014 16:07:48 +0000 (17:07 +0100)
winpr/libwinpr/sspi/NTLM/ntlm.c

index 9807460..34f6700 100644 (file)
@@ -198,7 +198,10 @@ NTLM_CONTEXT* ntlm_ContextNew()
                        char* workstation = (char*) malloc(dwSize + 1);
 
                        if (!workstation)
+                       {
+                               free (context);
                                return NULL;
+                       }
 
                        status = RegQueryValueExA(hKey, "WorkstationName", NULL, &dwType, (BYTE*) workstation, &dwSize);
                        workstation[dwSize] = '\0';
@@ -206,8 +209,7 @@ NTLM_CONTEXT* ntlm_ContextNew()
                        if (ntlm_SetContextWorkstation(context, workstation) < 0)
                        {
                                free(workstation);
-                               if (context)
-                                       free(context);
+                               free(context);
                                return NULL;
                        }