Fix more asprintf warnings and some error path errors.
[jra/samba/.git] / source3 / libads / util.c
index 9866a15285faaa2a17f0b4d209cedd17e9c9a631..2c7ccfebd6cf53cb826123866dcf4900f9839883 100644 (file)
@@ -71,7 +71,11 @@ ADS_STATUS ads_guess_service_principal(ADS_STRUCT *ads,
 
                strlower_m(server);
                strupper_m(server_realm);
-               asprintf(&princ, "ldap/%s@%s", server, server_realm);
+               if (asprintf(&princ, "ldap/%s@%s", server, server_realm) == -1) {
+                       SAFE_FREE(server);
+                       SAFE_FREE(server_realm);
+                       return ADS_ERROR(LDAP_NO_MEMORY);
+               }
 
                SAFE_FREE(server);
                SAFE_FREE(server_realm);
@@ -93,7 +97,11 @@ ADS_STATUS ads_guess_service_principal(ADS_STRUCT *ads,
 
                strlower_m(server);
                strupper_m(server_realm);
-               asprintf(&princ, "ldap/%s@%s", server, server_realm);
+               if (asprintf(&princ, "ldap/%s@%s", server, server_realm) == -1) {
+                       SAFE_FREE(server);
+                       SAFE_FREE(server_realm);
+                       return ADS_ERROR(LDAP_NO_MEMORY);
+               }
 
                SAFE_FREE(server);
                SAFE_FREE(server_realm);