Check for nan in another place in cxfa_graphics.cpp

Bug: chromium:952301
Change-Id: I47b23a3696381d251c043e0b77f3d6a3b8941cd3
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/53311
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/xfa/fxgraphics/cxfa_graphics.cpp b/xfa/fxgraphics/cxfa_graphics.cpp
index 8e11db4..d2c7189 100644
--- a/xfa/fxgraphics/cxfa_graphics.cpp
+++ b/xfa/fxgraphics/cxfa_graphics.cpp
@@ -6,6 +6,7 @@
 
 #include "xfa/fxgraphics/cxfa_graphics.h"
 
+#include <cmath>
 #include <memory>
 
 #include "core/fxge/cfx_defaultrenderdevice.h"
@@ -361,16 +362,14 @@
               continue;
             }
           }
-          if (s < 0) {
-            if (!m_info.fillColor.GetShading()->m_isExtendedBegin) {
+          if (std::isnan(s) || s < 0.0f) {
+            if (!m_info.fillColor.GetShading()->m_isExtendedBegin)
               continue;
-            }
-            s = 0;
+            s = 0.0f;
           }
           if (s > 1.0f) {
-            if (!m_info.fillColor.GetShading()->m_isExtendedEnd) {
+            if (!m_info.fillColor.GetShading()->m_isExtendedEnd)
               continue;
-            }
             s = 1.0f;
           }
           int index = (int32_t)(s * (FX_SHADING_Steps - 1));