layers: Fix a deref nullptr bug in StateTracker

Per Vulkan specs for VkGraphicsPipelineCreateInfo
(see https://www.khronos.org/registry/vulkan/specs/1.2-extensions/
man/html/VkGraphicsPipelineCreateInfo.html),
its pDynamicState member can be a nullptr. Dereferencing nullptr
could cause an undefined behavior.

Bug: 90846
Change-Id: I6790bf1606c0d6f61295964d3b233873e994b022
Reviewed-on: https://fuchsia-review.googlesource.com/c/third_party/Vulkan-ValidationLayers/+/626041
Reviewed-by: John Bauman <jbauman@google.com>
diff --git a/layers/state_tracker.cpp b/layers/state_tracker.cpp
index 68e5f4e..b0693d5 100644
--- a/layers/state_tracker.cpp
+++ b/layers/state_tracker.cpp
@@ -1,7 +1,7 @@
-/* Copyright (c) 2015-2021 The Khronos Group Inc.
- * Copyright (c) 2015-2021 Valve Corporation
- * Copyright (c) 2015-2021 LunarG, Inc.
- * Copyright (C) 2015-2021 Google Inc.
+/* Copyright (c) 2015-2022 The Khronos Group Inc.
+ * Copyright (c) 2015-2022 Valve Corporation
+ * Copyright (c) 2015-2022 LunarG, Inc.
+ * Copyright (C) 2015-2022 Google Inc.
  * Modifications Copyright (C) 2020 Advanced Micro Devices, Inc. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -2080,7 +2080,7 @@
         const auto *viewport_state = create_info.pViewportState;
         const auto *dynamic_state = create_info.pDynamicState;
         cb_state->status &= ~cb_state->static_status;
-        cb_state->static_status = MakeStaticStateMask(dynamic_state->ptr());
+        cb_state->static_status = MakeStaticStateMask(dynamic_state ? dynamic_state->ptr() : nullptr);
         cb_state->status |= cb_state->static_status;
         cb_state->dynamic_status = CBSTATUS_ALL_STATE_SET & (~cb_state->static_status);