bluetooth: Prevent aborts caused by invalid module arguments

If 'pa_modargs_new' returns a NULL, we need to be careful to not call
'pa_modargs_free' in the failure path since it requires that we pass it
a non-null argument. Also updates 'module-bluetooth-policy.c:pa__init'
to follow the standard "goto fail" pattern used everywhere else.

Signed-off-by: Jason Gerecke <killertofu@gmail.com>
This commit is contained in:
Jason Gerecke 2016-01-13 20:27:39 -08:00 committed by Arun Raghavan
parent f8c69de418
commit 00ba340618
2 changed files with 5 additions and 3 deletions

View file

@ -225,7 +225,7 @@ int pa__init(pa_module *m) {
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) { if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
pa_log_error("Failed to parse module arguments"); pa_log_error("Failed to parse module arguments");
return -1; goto fail;
} }
m->userdata = u = pa_xnew0(struct userdata, 1); m->userdata = u = pa_xnew0(struct userdata, 1);
@ -261,7 +261,8 @@ int pa__init(pa_module *m) {
return 0; return 0;
fail: fail:
pa_modargs_free(ma); if (ma)
pa_modargs_free(ma);
return -1; return -1;
} }

View file

@ -137,7 +137,8 @@ int pa__init(pa_module *m) {
return 0; return 0;
fail: fail:
pa_modargs_free(ma); if (ma)
pa_modargs_free(ma);
pa__done(m); pa__done(m);
return -1; return -1;
} }