Changeset 918 in openpam


Ignore:
Timestamp:
Feb 19, 2017, 5:46:22 PM (4 years ago)
Author:
Dag-Erling Smørgrav
Message:

Fix a bug that prevented the service name from being freed, thus
leaking a small amount of memory for every PAM session.

While there, eliminate an unnecessary variable.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/libpam/pam_set_item.c

    r913 r918  
    6161        const void *item)
    6262{
    63         void **slot, *tmp;
     63        void **slot;
    6464        size_t nsize, osize;
    6565
     
    7070        case PAM_SERVICE:
    7171                /* set once only, by pam_start() */
    72                 if (*slot != NULL)
     72                if (*slot != NULL && item != NULL)
    7373                        RETURNC(PAM_SYSTEM_ERR);
    7474                /* fall through */
     
    102102        }
    103103        if (item != NULL) {
    104                 if ((tmp = malloc(nsize)) == NULL)
     104                if ((*slot = malloc(nsize)) == NULL)
    105105                        RETURNC(PAM_BUF_ERR);
    106                 memcpy(tmp, item, nsize);
     106                memcpy(*slot, item, nsize);
    107107        } else {
    108                 tmp = NULL;
     108                *slot = NULL;
    109109        }
    110         *slot = tmp;
    111110        RETURNC(PAM_SUCCESS);
    112111}
Note: See TracChangeset for help on using the changeset viewer.