Branch: Tag:

2017-10-16

2017-10-16 09:59:49 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Mappings: Use sub_ref() when we know that we have extra refs.

Fixes some more of [CID 742747] and [CID 742750].

971: Inside #if defined(PIKE_DEBUG)
   Pike_fatal("Wrong dataset in mapping_insert!\n");    if(d_flag>1) check_mapping(m);   #endif -  free_mapping_data(md); +  /* NB: We know that md has a reference from the mapping +  * in addition to our reference. +  * +  * The use of sub_ref() silences warnings from Coverity, as well as +  * on the off chance of a reference counting error avoids accessing +  * freed memory. +  */ +  refs = sub_ref(md); /* free_mapping_data(md); */ +  assert(refs); +     if(!overwrite) return;    PREPARE_FOR_DATA_CHANGE2();    PROPAGATE(); /* propagate after preparing */
1102: Inside #if defined(PIKE_DEBUG)
   if(d_flag)    check_mapping(m);   #endif -  free_mapping_data(md); +  /* NB: We know that md has a reference from the mapping +  * in addition to our reference. +  * +  * The use of sub_ref() silences warnings from Coverity, as well as +  * on the off chance of a reference counting error avoids accessing +  * freed memory. +  */ +  refs = sub_ref(md); /* free_mapping_data(md); */ +  assert(refs); +     if(TYPEOF(k->val) == t)    {    PREPARE_FOR_DATA_CHANGE2();