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>
This commit is contained in:
@@ -1270,11 +1270,14 @@ llvmpipe_register_texture(struct llvmpipe_context *ctx, struct lp_texture_handle
|
||||
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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user