Skip to content

Commit cfb4b77

Browse files
alejandro-perezsimo5
authored andcommitted
Add cleanup function for mag_conn->name_attributes
Reviewed-by: Simo Sorce <simo@redhat.com> Closes #127
1 parent 9bd8462 commit cfb4b77

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

src/environ.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ static bool mag_get_name_attr(request_rec *req,
3535
return true;
3636
}
3737

38+
static apr_status_t mag_mc_name_attrs_cleanup(void *data)
39+
{
40+
struct mag_conn *mc = (struct mag_conn *)data;
41+
free(mc->name_attributes);
42+
mc->name_attributes = NULL;
43+
return 0;
44+
}
45+
3846
static void mc_add_name_attribute(struct mag_conn *mc,
3947
const char *name, const char *value)
4048
{
@@ -44,6 +52,8 @@ static void mc_add_name_attribute(struct mag_conn *mc,
4452
size = sizeof(struct mag_attr) * (mc->na_count + 16);
4553
mc->name_attributes = realloc(mc->name_attributes, size);
4654
if (!mc->name_attributes) apr_pool_abort_get(mc->pool)(ENOMEM);
55+
apr_pool_userdata_setn(mc, GSS_NAME_ATTR_USERDATA,
56+
mag_mc_name_attrs_cleanup, mc->pool);
4757
}
4858

4959
mc->name_attributes[mc->na_count].name = apr_pstrdup(mc->pool, name);

src/mod_auth_gssapi.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1601,8 +1601,6 @@ static const char *mag_negotiate_once(cmd_parms *parms, void *mconfig, int on)
16011601
return NULL;
16021602
}
16031603

1604-
#define GSS_NAME_ATTR_USERDATA "GSS Name Attributes Userdata"
1605-
16061604
static apr_status_t mag_name_attrs_cleanup(void *data)
16071605
{
16081606
struct mag_config *cfg = (struct mag_config *)data;

src/mod_auth_gssapi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
#endif
5454

5555
extern module AP_MODULE_DECLARE_DATA auth_gssapi_module;
56+
#define GSS_NAME_ATTR_USERDATA "GSS Name Attributes Userdata"
5657

5758
struct mag_na_map {
5859
char *env_name;

0 commit comments

Comments
 (0)