summaryrefslogtreecommitdiff
path: root/fpdfsdk/javascript/Document.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk/javascript/Document.cpp')
-rw-r--r--fpdfsdk/javascript/Document.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/fpdfsdk/javascript/Document.cpp b/fpdfsdk/javascript/Document.cpp
index d5875aca69..77f67b5c8f 100644
--- a/fpdfsdk/javascript/Document.cpp
+++ b/fpdfsdk/javascript/Document.cpp
@@ -1016,16 +1016,17 @@ bool Document::documentFileName(CJS_Runtime* pRuntime,
return false;
}
CFX_WideString wsFilePath = m_pFormFillEnv->JS_docGetFilePath();
- FX_STRSIZE i = wsFilePath.GetLength() - 1;
- for (; i >= 0; i--) {
- if (wsFilePath[i] == L'\\' || wsFilePath[i] == L'/')
+ FX_STRSIZE i = wsFilePath.GetLength();
+ for (; i > 0; i--) {
+ if (wsFilePath[i - 1] == L'\\' || wsFilePath[i - 1] == L'/')
break;
}
- if (i >= 0 && i < wsFilePath.GetLength() - 1) {
- vp << (wsFilePath.GetBuffer(wsFilePath.GetLength()) + i + 1);
- } else {
+
+ if (i > 0 && i < wsFilePath.GetLength())
+ vp << (wsFilePath.GetBuffer(wsFilePath.GetLength()) + i);
+ else
vp << L"";
- }
+
return true;
}