From: Alan T. DeKok Date: Fri, 11 Sep 2015 15:56:46 +0000 (-0400) Subject: Copy VPs instead of talloc_stealing them X-Git-Tag: release_3_0_10~122 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a529c2d9bdef0f635fa10b2ab7e05527f95551b2;p=thirdparty%2Ffreeradius-server.git Copy VPs instead of talloc_stealing them --- diff --git a/src/main/state.c b/src/main/state.c index d52edf20416..ecc68ef9903 100644 --- a/src/main/state.c +++ b/src/main/state.c @@ -397,9 +397,18 @@ void fr_state_get_vps(REQUEST *request, RADIUS_PACKET *packet) /* * This has to be done in a mutex lock, because talloc * isn't thread-safe. + * + * We also COPY the VPs instead of moving them. This is + * because moving does a talloc_steal(), which keeps the + * parent context around. */ if (entry) { - fr_pair_list_move_by_num(request, &request->state, &entry->vps, 0, 0, TAG_ANY); + VALUE_PAIR *vps; + + vps = fr_pair_list_copy_by_num(request, entry->vps, 0, 0, TAG_ANY); + fr_pair_list_move(request, &request->state, &vps); + fr_pair_list_free(&entry->vps); + RDEBUG2("session-state: Found cached attributes"); rdebug_pair_list(L_DBG_LVL_1, request, request->state, NULL); @@ -449,8 +458,13 @@ bool fr_state_put_vps(REQUEST *request, RADIUS_PACKET *original, RADIUS_PACKET * /* * This has to be done in a mutex lock, because talloc * isn't thread-safe. + * + * We also COPY the VPs instead of moving them. This is + * because moving does a talloc_steal(), which keeps the + * parent context around. */ - fr_pair_list_move_by_num(entry, &entry->vps, &request->state, 0, 0, TAG_ANY); + entry->vps = fr_pair_list_copy_by_num(request, request->state, 0, 0, TAG_ANY); + fr_pair_list_free(&request->state); PTHREAD_MUTEX_UNLOCK(&state->mutex); rad_assert(request->state == NULL);