vulkan/screenshot-layer: initialize info to NULL

Initialize 'info' to NULL to avoid use of potentially uninitialized
value at the cleanup label when an earlier error causes a goto before
png_create_info_struct() is reached.

screenshot.cpp:808:9: warning: variable 'info' is used uninitialized whenever 'if'
condition is true [-Wsometimes-uninitialized]
screenshot.cpp:814:9: warning: variable 'info' is used uninitialized whenever 'if'
condition is true [-Wsometimes-uninitialized]

Fixes: eda55c7c2f ("vulkan/screenshot-layer: Add Vulkan screenshot layer")
Signed-off-by: Vinson Lee <vlee@freedesktop.org>
Reviewed-by: Casey Bowman <casey.g.bowman@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41325>
(cherry picked from commit 4c46cd8e9d)
This commit is contained in:
Vinson Lee 2026-04-11 22:51:38 -07:00 committed by Eric Engestrom
parent 507d4edbc4
commit 84e530b09e
2 changed files with 2 additions and 2 deletions

View file

@ -514,7 +514,7 @@
"description": "vulkan/screenshot-layer: initialize info to NULL",
"nominated": true,
"nomination_type": 2,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "eda55c7c2f695492e8ebdd26725e5be5ee66eb1c",
"notes": null

View file

@ -790,7 +790,7 @@ void *writePNG(void *data) {
char *tmpFilename = (char *)malloc(length + 4); // Allow for ".tmp"
VkResult res;
png_byte *row_pointer;
png_infop info;
png_infop info = NULL;
png_struct* png;
uint64_t rowPitch = threadData->srLayout.rowPitch;
uint64_t start_time, end_time;