spa: fix spa_api_method_null macro NULL checks

What may be NULL in these methods is the pointer to the object
containing the spa_interface, not the interface pointer itself.

Fixes spa-acp-tool crashing with NULL deref in spa_i18n.
This commit is contained in:
Pauli Virtanen 2024-12-07 13:43:07 +02:00 committed by Wim Taymans
parent 2d30ab94c2
commit 61f9018e15
3 changed files with 14 additions and 10 deletions

View file

@ -64,7 +64,7 @@ SPA_FORMAT_ARG_FUNC(2)
SPA_API_I18N const char *
spa_i18n_text(struct spa_i18n *i18n, const char *msgid)
{
return spa_api_method_null_r(const char *, msgid, spa_i18n, &i18n->iface,
return spa_api_method_null_r(const char *, msgid, spa_i18n, i18n, &i18n->iface,
text, 0, msgid);
}
@ -73,7 +73,7 @@ spa_i18n_ntext(struct spa_i18n *i18n, const char *msgid,
const char *msgid_plural, unsigned long int n)
{
return spa_api_method_null_r(const char *, n == 1 ? msgid : msgid_plural,
spa_i18n, &i18n->iface, ntext, 0, msgid, msgid_plural, n);
spa_i18n, i18n, &i18n->iface, ntext, 0, msgid, msgid_plural, n);
}
/**

View file

@ -59,14 +59,14 @@ struct spa_plugin_loader_methods {
SPA_API_PLUGIN_LOADER struct spa_handle *
spa_plugin_loader_load(struct spa_plugin_loader *loader, const char *factory_name, const struct spa_dict *info)
{
return spa_api_method_null_r(struct spa_handle *, NULL, spa_plugin_loader, &loader->iface,
return spa_api_method_null_r(struct spa_handle *, NULL, spa_plugin_loader, loader, &loader->iface,
load, 0, factory_name, info);
}
SPA_API_PLUGIN_LOADER int
spa_plugin_loader_unload(struct spa_plugin_loader *loader, struct spa_handle *handle)
{
return spa_api_method_null_r(int, -1, spa_plugin_loader, &loader->iface,
return spa_api_method_null_r(int, -1, spa_plugin_loader, loader, &loader->iface,
unload, 0, handle);
}