mirror of git://git.sysmocom.de/ofono
hfpmodem: Avoid segfault in call-volume
The use of g_idle_add can cause a segmentation fault if the object is destroyed in the meantime.
This commit is contained in:
parent
c1ed32db9d
commit
6e5edc8ead
|
@ -50,6 +50,7 @@ struct cv_data {
|
||||||
GAtChat *chat;
|
GAtChat *chat;
|
||||||
unsigned char sp_volume;
|
unsigned char sp_volume;
|
||||||
unsigned char mic_volume;
|
unsigned char mic_volume;
|
||||||
|
guint register_source;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void cv_generic_set_cb(gboolean ok, GAtResult *result,
|
static void cv_generic_set_cb(gboolean ok, GAtResult *result,
|
||||||
|
@ -173,6 +174,8 @@ static gboolean hfp_call_volume_register(gpointer user_data)
|
||||||
|
|
||||||
DBG("");
|
DBG("");
|
||||||
|
|
||||||
|
vd->register_source = 0;
|
||||||
|
|
||||||
g_at_chat_register(vd->chat, "+VGS:", vgs_notify, FALSE, cv, NULL);
|
g_at_chat_register(vd->chat, "+VGS:", vgs_notify, FALSE, cv, NULL);
|
||||||
g_at_chat_register(vd->chat, "+VGM:", vgm_notify, FALSE, cv, NULL);
|
g_at_chat_register(vd->chat, "+VGM:", vgm_notify, FALSE, cv, NULL);
|
||||||
|
|
||||||
|
@ -197,7 +200,7 @@ static int hfp_call_volume_probe(struct ofono_call_volume *cv,
|
||||||
|
|
||||||
ofono_call_volume_set_data(cv, vd);
|
ofono_call_volume_set_data(cv, vd);
|
||||||
|
|
||||||
g_idle_add(hfp_call_volume_register, cv);
|
vd->register_source = g_idle_add(hfp_call_volume_register, cv);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -206,6 +209,9 @@ static void hfp_call_volume_remove(struct ofono_call_volume *cv)
|
||||||
{
|
{
|
||||||
struct cv_data *vd = ofono_call_volume_get_data(cv);
|
struct cv_data *vd = ofono_call_volume_get_data(cv);
|
||||||
|
|
||||||
|
if (vd->register_source != 0)
|
||||||
|
g_source_remove(vd->register_source);
|
||||||
|
|
||||||
ofono_call_volume_set_data(cv, NULL);
|
ofono_call_volume_set_data(cv, NULL);
|
||||||
|
|
||||||
g_at_chat_unref(vd->chat);
|
g_at_chat_unref(vd->chat);
|
||||||
|
|
Loading…
Reference in New Issue