Prevent some DCHECK failures in CFXJSE_Value.
BUG=pdfium:1246
Change-Id: I172d43e314c1cdb5c2ad67cf5cb6eb37915b0049
Reviewed-on: https://pdfium-review.googlesource.com/c/50970
Reviewed-by: dsinclair <dsinclair@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/fxjs/xfa/cfxjse_formcalc_context.cpp b/fxjs/xfa/cfxjse_formcalc_context.cpp
index 6fb3459..547d978 100644
--- a/fxjs/xfa/cfxjse_formcalc_context.cpp
+++ b/fxjs/xfa/cfxjse_formcalc_context.cpp
@@ -5832,9 +5832,8 @@
}
if (arg->IsString())
return strtof(arg->ToString().c_str(), nullptr);
- if (arg->IsUndefined())
- return 0;
-
+ if (arg->IsUndefined() || arg->IsEmpty())
+ return 0.0f;
return arg->ToFloat();
}
@@ -5866,7 +5865,7 @@
}
if (arg->IsString())
return strtod(arg->ToString().c_str(), nullptr);
- if (arg->IsUndefined())
+ if (arg->IsUndefined() || arg->IsEmpty())
return 0;
return arg->ToDouble();
}
@@ -5908,7 +5907,7 @@
// static
ByteString CFXJSE_FormCalcContext::ValueToUTF8String(CFXJSE_Value* arg) {
- if (!arg || arg->IsNull() || arg->IsUndefined())
+ if (!arg || arg->IsNull() || arg->IsUndefined() || arg->IsEmpty())
return ByteString();
if (arg->IsBoolean())
return arg->ToBoolean() ? "1" : "0";