[PATCH 0/1] MR6698: wined3d: Check that format_id is >= 0 before assuming it's an index.
Some FOURCC values such as 0xdeadbeef will en up being negative when cast to the enum type, and may cause a random crash later on. This happens randomly in the ddraw tests, depending on the compiler being used. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/6698
From: Rémi Bernon <rbernon(a)codeweavers.com> Some FOURCC values such as 0xdeadbeef will en up being negative when cast to the enum type, and may cause a random crash later on. This happens randomly in the ddraw tests, depending on the compiler being used. --- dlls/wined3d/utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index 30572bc0ded..181914986f6 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -1933,7 +1933,7 @@ static inline int get_format_idx(enum wined3d_format_id format_id) { unsigned int i; - if (format_id < WINED3D_FORMAT_FOURCC_BASE) + if (format_id >= 0 && format_id < WINED3D_FORMAT_FOURCC_BASE) return format_id; for (i = 0; i < ARRAY_SIZE(format_index_remap); ++i) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/6698
This merge request was approved by Elizabeth Figura. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/6698
This merge request was approved by Jan Sikorski. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/6698
This causes a warning with clang: ``` dlls/wined3d/utils.c:1936:19: warning: result of comparison of unsigned enum expression >= 0 is always true [-Wtautological-unsigned-enum-zero-compare] ``` -- https://gitlab.winehq.org/wine/wine/-/merge_requests/6698#note_86688
On Wed Nov 6 01:33:33 2024 +0000, Alexandre Julliard wrote:
This causes a warning with clang: ``` dlls/wined3d/utils.c:1936:19: warning: result of comparison of unsigned enum expression >= 0 is always true [-Wtautological-unsigned-enum-zero-compare] ``` Considering the enum behavior is fairly compiler-specific, maybe casting the `format_id` variable in the original `if` statement to unsigned would work for this issue too?
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/6698#note_86692
participants (5)
-
Aida Jonikienė -
Alexandre Julliard (@julliard) -
Elizabeth Figura (@zfigura) -
Jan Sikorski (@jsikorski) -
Rémi Bernon