vkd3d-shader: Avoid passing NULL to qsort(). (ubsan)

Otherwise ubsan reports runtime errors such as:

    libs/vkd3d-shader/ir.c:4731:5: runtime error: null pointer passed as argument 1, which is declared to never be null
This commit is contained in:
Francisco Casas 2024-12-18 16:30:53 -03:00 committed by Henri Verbeet
parent eaf4d0bfbf
commit 7b23cd4d3c
Notes: Henri Verbeet 2025-01-10 20:15:12 +01:00
Approved-by: Elizabeth Figura (@zfigura)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1327
3 changed files with 7 additions and 4 deletions

View File

@ -10280,7 +10280,8 @@ struct extern_resource *sm4_get_extern_resources(struct hlsl_ctx *ctx, unsigned
++*count;
}
qsort(extern_resources, *count, sizeof(*extern_resources), sm4_compare_extern_resources);
if (extern_resources)
qsort(extern_resources, *count, sizeof(*extern_resources), sm4_compare_extern_resources);
return extern_resources;
}

View File

@ -4775,7 +4775,8 @@ static enum vkd3d_result vsir_cfg_generate_synthetic_loop_intervals(struct vsir_
}
}
qsort(cfg->loop_intervals, cfg->loop_interval_count, sizeof(*cfg->loop_intervals), compare_loop_intervals);
if (cfg->loop_intervals)
qsort(cfg->loop_intervals, cfg->loop_interval_count, sizeof(*cfg->loop_intervals), compare_loop_intervals);
if (TRACE_ON())
for (i = 0; i < cfg->loop_interval_count; ++i)

View File

@ -578,8 +578,9 @@ static HRESULT d3d12_root_signature_info_from_desc(struct d3d12_root_signature_i
goto done;
}
qsort(info->ranges, info->range_count, sizeof(*info->ranges),
d3d12_root_signature_info_range_compare);
if (info->ranges)
qsort(info->ranges, info->range_count, sizeof(*info->ranges),
d3d12_root_signature_info_range_compare);
for (i = D3D12_SHADER_VISIBILITY_VERTEX; i <= D3D12_SHADER_VISIBILITY_MESH; ++i)
{