mesa: clear reserved parameter storage because it's stored in the shader cache

The elements might not be initialized and we don't want random bytes
in the shader cache.

Discovered by valgrind.

Reviewed-by: Zoltán Böszörményi <zboszor@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9360>
This commit is contained in:
Marek Olšák
2021-03-02 01:07:10 -05:00
committed by Marge Bot
parent bcc61a01d4
commit 94f41b8a09
+4
View File
@@ -220,6 +220,7 @@ _mesa_reserve_parameter_storage(struct gl_program_parameter_list *paramList,
}
if (needSizeValues > paramList->SizeValues) {
unsigned oldSize = paramList->SizeValues;
paramList->SizeValues = needSizeValues + 16; /* alloc some extra */
paramList->ParameterValues = (gl_constant_value *)
@@ -231,6 +232,9 @@ _mesa_reserve_parameter_storage(struct gl_program_parameter_list *paramList,
*/
paramList->SizeValues * sizeof(gl_constant_value) +
12, 16);
/* The values are written to the shader cache, so clear them. */
memset(paramList->ParameterValues + oldSize, 0,
(paramList->SizeValues - oldSize) * sizeof(gl_constant_value));
}
}