]> granicus.if.org Git - linux-pam/commitdiff
pam_start: fix memory leak on error path
authorDmitry V. Levin <ldv@altlinux.org>
Mon, 26 Dec 2011 18:10:29 +0000 (18:10 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Mon, 26 Dec 2011 18:10:29 +0000 (18:10 +0000)
* libpam/pam_start.c (pam_start): If _pam_make_env() or
_pam_init_handlers() returned an error, release the memory allocated
for pam_conv structure.

Patch-by: cancel <suntsu@yandex.ru>.
libpam/pam_start.c

index b7cd771e26eba806620ac871529e2c81e87c572b..328416d274298a8fe962118ec900321a65d6418b 100644 (file)
@@ -111,6 +111,7 @@ int pam_start (
     (*pamh)->data = NULL;
     if ( _pam_make_env(*pamh) != PAM_SUCCESS ) {
        pam_syslog(*pamh,LOG_ERR,"pam_start: failed to initialize environment");
+       _pam_drop((*pamh)->pam_conversation);
        _pam_drop((*pamh)->service_name);
        _pam_drop((*pamh)->user);
        _pam_drop(*pamh);
@@ -127,6 +128,7 @@ int pam_start (
     if ( _pam_init_handlers(*pamh) != PAM_SUCCESS ) {
        pam_syslog(*pamh, LOG_ERR, "pam_start: failed to initialize handlers");
        _pam_drop_env(*pamh);                 /* purge the environment */
+       _pam_drop((*pamh)->pam_conversation);
        _pam_drop((*pamh)->service_name);
        _pam_drop((*pamh)->user);
        _pam_drop(*pamh);