ShaderChecker: do not crash if Shader output count == 0 and PSO attachments count > 0

(cherry picked from commit 80bb5d63774f2e11bc14d9c5291bb3273f0e79cf)
diff --git a/layers/shader_checker.cpp b/layers/shader_checker.cpp
index 8e08b37..0fa0812 100644
--- a/layers/shader_checker.cpp
+++ b/layers/shader_checker.cpp
@@ -715,7 +715,7 @@
      */
 
     while ((outputs.size() > 0 && it != outputs.end()) || attachment < cb->attachmentCount) {
-        if (attachment == cb->attachmentCount || it->first < attachment) {
+        if (attachment == cb->attachmentCount || ( it != outputs.end() && it->first < attachment)) {
             sprintf(str, "FS writes to output location %d with no matching attachment", it->first);
             layerCbMsg(VK_DBG_MSG_WARNING, VK_VALIDATION_LEVEL_0, NULL, 0, SHADER_CHECKER_OUTPUT_NOT_CONSUMED, "SC", str);
             it++;