capi_get_provname: free name on error if it was malloc'ed
authorJonas Maebe <jonas.maebe@elis.ugent.be>
Sun, 8 Dec 2013 22:04:54 +0000 (23:04 +0100)
committerKurt Roeckx <kurt@roeckx.be>
Thu, 4 Dec 2014 22:48:44 +0000 (23:48 +0100)
Signed-off-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Richard Levitte <levitte@openssl.org>
engines/e_capi.c

index d4221cb..f06d298 100644 (file)
@@ -1155,6 +1155,8 @@ static int capi_get_provname(CAPI_CTX *ctx, LPSTR *pname, DWORD *ptype, DWORD id
        if (!CryptEnumProviders(idx, NULL, 0, ptype, name, &len))
                {
                err = GetLastError();
        if (!CryptEnumProviders(idx, NULL, 0, ptype, name, &len))
                {
                err = GetLastError();
+               if (sizeof(TCHAR) == sizeof(char))
+                       OPENSSL_free(name);
                if (err == ERROR_NO_MORE_ITEMS)
                        return 2;
                CAPIerr(CAPI_F_CAPI_GET_PROVNAME, CAPI_R_CRYPTENUMPROVIDERS_ERROR);
                if (err == ERROR_NO_MORE_ITEMS)
                        return 2;
                CAPIerr(CAPI_F_CAPI_GET_PROVNAME, CAPI_R_CRYPTENUMPROVIDERS_ERROR);