util/format: initialize non-important components to 0
authorMarcin Ślusarz <marcin.slusarz@intel.com>
Fri, 24 Jul 2020 16:59:41 +0000 (18:59 +0200)
committerMarge Bot <eric+marge@anholt.net>
Thu, 30 Jul 2020 10:41:00 +0000 (10:41 +0000)
Avoids copying random garbage from the stack.

Found by Coverity.

Signed-off-by: Marcin Ślusarz <marcin.slusarz@intel.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6067>

src/util/format/u_format_pack.py

index 3307027bbbd3c836ce427b7bd14fc83ffcd72b09..15c6be72e158de910b6e117c565039dfa5388497 100644 (file)
@@ -593,7 +593,7 @@ def generate_pack_kernel(format, src_channel, src_native_type):
     def pack_into_struct(channels, swizzles):
         inv_swizzle = inv_swizzles(swizzles)
 
-        print('         struct util_format_%s pixel;' % format.short_name())
+        print('         struct util_format_%s pixel = {0};' % format.short_name())
     
         for i in range(4):
             dst_channel = channels[i]