Skip to content

Commit 6616c48

Browse files
committed
Fix nullpointer dereference at VKJson
Set array values of VkPhysicalDeviceVulkan14Properties. Contributers- [email protected] Test: adb shell cmd gpu vkjson Flag: NONE infeasible Bug: b/403413507 Change-Id: I8df894343ec759f00f56d55f21a6ed533a15a460
1 parent fe45ac6 commit 6616c48

File tree

3 files changed

+44
-4
lines changed

3 files changed

+44
-4
lines changed

vulkan/vkjson/vkjson.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
#include <type_traits>
3737
#include <utility>
3838

39+
/*
40+
* This file is autogenerated by vkjson_generator.py. Do not edit directly.
41+
*/
3942
namespace {
4043

4144
/*

vulkan/vkjson/vkjson.h

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
#undef max
3434
#endif
3535

36+
/*
37+
* This file is autogenerated by vkjson_generator.py. Do not edit directly.
38+
*/
3639
struct VkJsonLayer {
3740
VkLayerProperties properties;
3841
std::vector<VkExtensionProperties> extensions;
@@ -263,23 +266,41 @@ struct VkJsonKHRDriverProperties {
263266
};
264267

265268
struct VkJsonCore11 {
269+
VkJsonCore11() {
270+
memset(&properties, 0, sizeof(VkPhysicalDeviceVulkan11Properties));
271+
memset(&features, 0, sizeof(VkPhysicalDeviceVulkan11Features));
272+
}
266273
VkPhysicalDeviceVulkan11Properties properties;
267274
VkPhysicalDeviceVulkan11Features features;
268275
};
269276

270277
struct VkJsonCore12 {
278+
VkJsonCore12() {
279+
memset(&properties, 0, sizeof(VkPhysicalDeviceVulkan12Properties));
280+
memset(&features, 0, sizeof(VkPhysicalDeviceVulkan12Features));
281+
}
271282
VkPhysicalDeviceVulkan12Properties properties;
272283
VkPhysicalDeviceVulkan12Features features;
273284
};
274285

275286
struct VkJsonCore13 {
287+
VkJsonCore13() {
288+
memset(&properties, 0, sizeof(VkPhysicalDeviceVulkan13Properties));
289+
memset(&features, 0, sizeof(VkPhysicalDeviceVulkan13Features));
290+
}
276291
VkPhysicalDeviceVulkan13Properties properties;
277292
VkPhysicalDeviceVulkan13Features features;
278293
};
279294

280295
struct VkJsonCore14 {
296+
VkJsonCore14() {
297+
memset(&properties, 0, sizeof(VkPhysicalDeviceVulkan14Properties));
298+
memset(&features, 0, sizeof(VkPhysicalDeviceVulkan14Features));
299+
}
281300
VkPhysicalDeviceVulkan14Properties properties;
282301
VkPhysicalDeviceVulkan14Features features;
302+
std::vector<VkImageLayout> copy_src_layouts;
303+
std::vector<VkImageLayout> copy_dst_layouts;
283304
};
284305

285306
struct VkJsonDevice {
@@ -306,10 +327,6 @@ struct VkJsonDevice {
306327
sizeof(VkPhysicalDeviceSamplerYcbcrConversionFeatures));
307328
memset(&shader_draw_parameter_features, 0,
308329
sizeof(VkPhysicalDeviceShaderDrawParameterFeatures));
309-
memset(&core11, 0, sizeof(VkJsonCore11));
310-
memset(&core12, 0, sizeof(VkJsonCore12));
311-
memset(&core13, 0, sizeof(VkJsonCore13));
312-
memset(&core14, 0, sizeof(VkJsonCore14));
313330
}
314331
VkJsonKHRVariablePointers khr_variable_pointers;
315332
VkJsonKHRShaderFloat16Int8 khr_shader_float16_int8;

vulkan/vkjson/vkjson_instance.cc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
#include <algorithm>
2828
#include <utility>
2929

30+
/*
31+
* This file is autogenerated by vkjson_generator.py. Do not edit directly.
32+
*/
3033
namespace {
3134

3235
bool EnumerateExtensions(const char* layer_name,
@@ -512,6 +515,23 @@ VkJsonDevice VkJsonGetDevice(VkPhysicalDevice physical_device) {
512515

513516
vkGetPhysicalDeviceProperties2(physical_device, &properties);
514517

518+
if (device.core14.properties.copySrcLayoutCount > 0 ||
519+
device.core14.properties.copyDstLayoutCount > 0) {
520+
if (device.core14.properties.copySrcLayoutCount > 0) {
521+
device.core14.copy_src_layouts.resize(
522+
device.core14.properties.copySrcLayoutCount);
523+
device.core14.properties.pCopySrcLayouts =
524+
device.core14.copy_src_layouts.data();
525+
}
526+
if (device.core14.properties.copyDstLayoutCount > 0) {
527+
device.core14.copy_dst_layouts.resize(
528+
device.core14.properties.copyDstLayoutCount);
529+
device.core14.properties.pCopyDstLayouts =
530+
device.core14.copy_dst_layouts.data();
531+
}
532+
vkGetPhysicalDeviceProperties2(physical_device, &properties);
533+
}
534+
515535
device.core14.features.sType =
516536
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_4_FEATURES;
517537
device.core14.features.pNext = features.pNext;

0 commit comments

Comments
 (0)