]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_pjsip_outbound_registration: Fix leak on vector add failure.
authorCorey Farrell <git@cfware.com>
Mon, 6 Nov 2017 23:55:00 +0000 (18:55 -0500)
committerCorey Farrell <git@cfware.com>
Mon, 6 Nov 2017 23:56:33 +0000 (18:56 -0500)
Change-Id: I774b88b3c9da41edd4dc8d78f095481f52f2bd46

res/res_pjsip_outbound_registration.c

index 731a1a93988d2c87abed3d6a2f84f78b4d1880cb..0b177ae3223853bd28860c355deb2ee24557cd66 100644 (file)
@@ -1386,10 +1386,10 @@ static int sip_outbound_registration_perform(void *data)
 
        AST_VECTOR_INIT(&state->client_state->outbound_auths, AST_VECTOR_SIZE(&registration->outbound_auths));
        for (i = 0; i < AST_VECTOR_SIZE(&registration->outbound_auths); ++i) {
-               const char *name = ast_strdup(AST_VECTOR_GET(&registration->outbound_auths, i));
+               char *name = ast_strdup(AST_VECTOR_GET(&registration->outbound_auths, i));
 
-               if (name) {
-                       AST_VECTOR_APPEND(&state->client_state->outbound_auths, name);
+               if (name && AST_VECTOR_APPEND(&state->client_state->outbound_auths, name)) {
+                       ast_free(name);
                }
        }
        state->client_state->retry_interval = registration->retry_interval;