mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 07:28:11 +02:00
lp: Don't allocate sampler functions if count is 0
This prevents memory being allocated with a size
of 0 as the sampler count will be 0.
Fixes: #13539
Co-authored-by: Stéphane Cerveau <scerveau@igalia.com>
Reviewed-by: Konstantin Seurer <konstantin.seurer@gmail.com>
Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36165>
(cherry picked from commit b781ae57a5)
This commit is contained in:
parent
28f746569c
commit
13e1adcd0f
2 changed files with 9 additions and 6 deletions
|
|
@ -3634,7 +3634,7 @@
|
|||
"description": "lp: Don't allocate sampler functions if count is 0",
|
||||
"nominated": true,
|
||||
"nomination_type": 1,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": null,
|
||||
"notes": null
|
||||
|
|
|
|||
|
|
@ -874,11 +874,14 @@ llvmpipe_register_texture(struct llvmpipe_context *ctx, struct lp_static_texture
|
|||
simple_mtx_lock(&matrix->lock);
|
||||
|
||||
if (entry->sampled) {
|
||||
if (entry->sample_functions) {
|
||||
entry->sample_functions = realloc(entry->sample_functions, matrix->sampler_count * sizeof(void **));
|
||||
memset(entry->sample_functions + entry->sampler_count, 0, (matrix->sampler_count - entry->sampler_count) * sizeof(void **));
|
||||
} else {
|
||||
entry->sample_functions = calloc(matrix->sampler_count, sizeof(void **));
|
||||
if (matrix->sampler_count > 0) {
|
||||
if (entry->sample_functions) {
|
||||
entry->sample_functions = realloc(entry->sample_functions, matrix->sampler_count * sizeof(void **));
|
||||
memset(entry->sample_functions + entry->sampler_count, 0,
|
||||
(matrix->sampler_count - entry->sampler_count) * sizeof(void **));
|
||||
} else {
|
||||
entry->sample_functions = calloc(matrix->sampler_count, sizeof(void **));
|
||||
}
|
||||
}
|
||||
entry->sampler_count = matrix->sampler_count;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue