Sfoglia il codice sorgente

dialog(k): avoid double free

- rested current dialog pointer when distroying dialog to avoid double
  free done from post script callback
- reported by Klaus Feichtinger
Daniel-Constantin Mierla 16 anni fa
parent
commit
9dca824052

+ 4 - 0
modules_k/dialog/dlg_hash.c

@@ -153,6 +153,9 @@ inline void destroy_dlg(struct dlg_cell *dlg)
 
 	run_dlg_callbacks( DLGCB_DESTROY , dlg, 0, DLG_DIR_NONE, 0);
 
+	if(dlg==get_current_dlg_pointer())
+		reset_current_dlg_pointer();
+
 	if (dlg->cbs.first)
 		destroy_dlg_callbacks_list(dlg->cbs.first);
 
@@ -172,6 +175,7 @@ inline void destroy_dlg(struct dlg_cell *dlg)
 		shm_free(dlg->cseq[DLG_CALLEE_LEG].s);
 
 	shm_free(dlg);
+	dlg = 0;
 }
 
 

+ 10 - 0
modules_k/dialog/dlg_profile.c

@@ -69,6 +69,16 @@ static struct dlg_profile_table* new_dlg_profile( str *name,
 		unsigned int size, unsigned int has_value);
 
 
+struct dlg_cell *get_current_dlg_pointer(void)
+{
+	return current_dlg_pointer;
+}
+
+void reset_current_dlg_pointer(void)
+{
+	current_dlg_pointer = NULL;
+}
+
 /*!
  * \brief Add profile definitions to the global list
  * \see new_dlg_profile

+ 4 - 0
modules_k/dialog/dlg_profile.h

@@ -79,6 +79,10 @@ struct dlg_profile_table {
 };
 
 
+struct dlg_cell *get_current_dlg_pointer(void);
+
+void reset_current_dlg_pointer(void);
+
 /*!
  * \brief Add profile definitions to the global list
  * \see new_dlg_profile