#31 Bug 1750893: Memory leak when slapi-nis return entries retrieved from nsswitch
Merged 4 years ago by abbra. Opened 4 years ago by tbordaz.
tbordaz/slapi-nis bz_1750893  into  master

file modified
+40
@@ -1649,6 +1649,45 @@ 

  	cbdata->entries_tail = NULL;

  }

  

+ static void

+ backend_search_free_staged(struct backend_search_cbdata *cbdata)

+ {

+ 	struct backend_staged_search *staged, *next;

+ 	int i;

+ 	int nb_entries = 0;

+ 	int nb_stages = 0;

+ 

+ 	if (cbdata == NULL) {

+ 		return;

+ 	}

+ 

+ 	staged = cbdata->staged;

+ 	while (staged != NULL) {

+ 		nb_stages++;

+ 		for (i = 0;

+ 				(i < staged->count) &&

+ 				(staged->entries != NULL) &&

+ 				(staged->entries[i] != NULL);

+ 				i++) {

+ 			slapi_entry_free(staged->entries[i]);

+ 			staged->entries[i] = NULL;

+ 		}

+ 		nb_entries += i;

+ 		slapi_ch_free_string(&staged->map_group);

+ 		slapi_ch_free_string(&staged->map_set);

+ 		slapi_ch_free_string(&staged->name);

+ 		slapi_ch_free_string(&staged->container_sdn);

+ 		next = staged->next;

+ 		free(staged);

+ 		staged = next;

+ 	}

+ 	slapi_log_error(SLAPI_LOG_PLUGIN,

+ 			cbdata->state->plugin_desc->spd_id,

+ 			"backend_search_free_staged freed %d stages with %d entries\n",

+ 			nb_stages,

+ 			nb_entries);

+ 	cbdata->staged = NULL;

+ }

  static int

  backend_search_cb(Slapi_PBlock *pb)

  {
@@ -1853,6 +1892,7 @@ 

  			map_unlock();

  			/* Return newly acquired entries */

  			backend_send_mapped_entries(&cbdata);

+ 			backend_search_free_staged(&cbdata);

  		} else {

  			slapi_log_error(SLAPI_LOG_PLUGIN,

  					cbdata.state->plugin_desc->spd_id,

When slapi-nis retrieves the entries addec by nsswitch search
it fills 'staged' structures.
Those structures should be freed once the entries have been returned

https://bugzilla.redhat.com/show_bug.cgi?id=1750893

rebased onto 89ddcd531110a58ee4644a3ea8b8051544507387

4 years ago

rebased onto 891138a

4 years ago

Pull-Request has been merged by abbra

4 years ago
Metadata