mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-19 07:00:10 -05:00
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:
parent
2d30ab94c2
commit
61f9018e15
3 changed files with 14 additions and 10 deletions
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -285,20 +285,24 @@ struct spa_interface {
|
|||
_res, method, version, ##__VA_ARGS__); \
|
||||
_res; \
|
||||
})
|
||||
#define spa_api_method_null_v(type,o,method,version,...) \
|
||||
#define spa_api_method_null_v(type,co,o,method,version,...) \
|
||||
({ \
|
||||
struct spa_interface *_i = o; \
|
||||
if (SPA_LIKELY(_i != NULL)) \
|
||||
struct type *_co = co; \
|
||||
if (SPA_LIKELY(_co != NULL)) { \
|
||||
struct spa_interface *_i = o; \
|
||||
spa_interface_call(_i, struct type ##_methods, \
|
||||
method, version, ##__VA_ARGS__); \
|
||||
} \
|
||||
})
|
||||
#define spa_api_method_null_r(rtype,def,type,o,method,version,...) \
|
||||
#define spa_api_method_null_r(rtype,def,type,co,o,method,version,...) \
|
||||
({ \
|
||||
rtype _res = def; \
|
||||
struct spa_interface *_i = o; \
|
||||
if (SPA_LIKELY(_i != NULL)) \
|
||||
struct type *_co = co; \
|
||||
if (SPA_LIKELY(_co != NULL)) { \
|
||||
struct spa_interface *_i = o; \
|
||||
spa_interface_call_res(_i, struct type ##_methods, \
|
||||
_res, method, version, ##__VA_ARGS__); \
|
||||
} \
|
||||
_res; \
|
||||
})
|
||||
#define spa_api_method_fast_v(type,o,method,version,...) \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue