[PATCH 0/1] MR3280: widl: Stop possible null dereference (Coverity)
From: Alistair Leslie-Hughes <leslie_alistair(a)hotmail.com> --- tools/widl/header.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/widl/header.c b/tools/widl/header.c index b7497e215d5..554b40fa46f 100644 --- a/tools/widl/header.c +++ b/tools/widl/header.c @@ -184,8 +184,9 @@ static void write_fields(FILE *h, var_list_t *fields, enum name_type name_type) } LIST_FOR_EACH_ENTRY( v, fields, var_t, entry ) { - expr_t *contract = get_attrp(v->attrs, ATTR_CONTRACT); + expr_t *contract; if (!v || !v->declspec.type) continue; + contract = get_attrp(v->attrs, ATTR_CONTRACT); if (contract) write_apicontract_guard_start(h, contract); indent(h, 0); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/3280
This merge request was approved by Huw Davies. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/3280
Alexandre Julliard (@julliard) commented about tools/widl/header.c:
}
LIST_FOR_EACH_ENTRY( v, fields, var_t, entry ) { - expr_t *contract = get_attrp(v->attrs, ATTR_CONTRACT); + expr_t *contract; if (!v || !v->declspec.type) continue; + contract = get_attrp(v->attrs, ATTR_CONTRACT); if (contract) write_apicontract_guard_start(h, contract);
A list entry can never be NULL. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/3280#note_38632
On Tue Jul 11 09:25:53 2023 +0000, Alexandre Julliard wrote:
A list entry can never be NULL. Right... So the correct fix would be to remove the `!v` check, both here and in the previous loop.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/3280#note_38634
participants (4)
-
Alexandre Julliard (@julliard) -
Alistair Leslie-Hughes -
Alistair Leslie-Hughes (@alesliehughes) -
Huw Davies (@huw)