Fix crash in Viewer when attempting to view shaders in Metal.
Change-Id: Ia19063f13e74d7dc2f1ead1fad20ad6828a3648d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/298742
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
diff --git a/tools/viewer/Viewer.cpp b/tools/viewer/Viewer.cpp
index 973171a..ec69093 100644
--- a/tools/viewer/Viewer.cpp
+++ b/tools/viewer/Viewer.cpp
@@ -2297,7 +2297,8 @@
SkSL::String highlight;
if (!sksl) {
- highlight = shaderCaps->versionDeclString();
+ const char* versionDecl = shaderCaps->versionDeclString();
+ highlight = versionDecl ? versionDecl : "";
if (shaderCaps->usesPrecisionModifiers()) {
highlight.append("precision mediump float;\n");
}