fix possible crash when freeing pulse sinks

SVN revision: 64648
This commit is contained in:
Mike Blumenkrantz 2011-11-02 14:42:20 +00:00
parent d4c9dceed4
commit c960c47c58
2 changed files with 13 additions and 8 deletions

View File

@ -459,6 +459,7 @@ struct Pulse_Sink {
Eina_Bool mute : 1; /**< Mute switch of the sink */ Eina_Bool mute : 1; /**< Mute switch of the sink */
Eina_Bool update : 1; Eina_Bool update : 1;
Eina_Bool source : 1; /**< sink is actually a source */ Eina_Bool source : 1; /**< sink is actually a source */
Eina_Bool deleted : 1; /**< sink has been deleted */
}; };
typedef uint32_t pa_pstream_descriptor[PA_PSTREAM_DESCRIPTOR_MAX]; typedef uint32_t pa_pstream_descriptor[PA_PSTREAM_DESCRIPTOR_MAX];

View File

@ -164,15 +164,19 @@ pulse_sink_free(Pulse_Sink *sink)
{ {
Pulse_Sink_Port_Info *pi; Pulse_Sink_Port_Info *pi;
if (!sink) return; if (!sink) return;
if (sink->source) if (!sink->deleted)
{ {
if (eina_hash_del_by_key(pulse_sources, (uintptr_t*)&sink->index)) sink->deleted = EINA_TRUE;
return; if (sink->source)
} {
else eina_hash_del_by_key(pulse_sources, (uintptr_t*)&sink->index);
{ return;
if (eina_hash_del_by_key(pulse_sinks, (uintptr_t*)&sink->index)) }
return; else
{
eina_hash_del_by_key(pulse_sinks, (uintptr_t*)&sink->index);
return;
}
} }
eina_stringshare_del(sink->name); eina_stringshare_del(sink->name);
eina_stringshare_del(sink->description); eina_stringshare_del(sink->description);