> if (display_value != NULL) { > if (code != 0) > code = data_to_gss(&kdisplay_value, display_value); > else > free(kdisplay_value.data); > } Also, in the same region of code: If the call data_to_gss(&kdisplay_value, display_value) fails with an error (which can only happen #ifdef _WIN32), the preceding call data_to_gss(&kvalue, value) has now passed responsibility for the buffer value->value to the caller even though krb5_gss_get_name_attribute() is returning a failure code. In this case, one solution would be to free value->value, and since kvalue now has empty data, repeat the call data_to_gss(&kvalue, value) which shouldn't fail as it shouldn't have to allocate anything. if (display_value != NULL) { if (code == 0) { code = data_to_gss(&kdisplay_value, display_value); if (code != 0 && value != NULL) { /* Cleanup. N.B. kvalue is empty_data() */ free(value->value); data_to_gss(&kvalue, value); } } else free(kdisplay_value.data); }