Convert CPDF_PageLabel::GetLabel to return Optional<WideString>
Change-Id: I53b91aa89c0fd1e7ab766f6d3c27a0fc7573c360
Reviewed-on: https://pdfium-review.googlesource.com/22290
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
diff --git a/fpdfsdk/fpdfdoc.cpp b/fpdfsdk/fpdfdoc.cpp
index 51a1c61..14e4361 100644
--- a/fpdfsdk/fpdfdoc.cpp
+++ b/fpdfsdk/fpdfdoc.cpp
@@ -424,8 +424,8 @@
// CPDF_PageLabel can deal with NULL |document|.
CPDF_PageLabel label(CPDFDocumentFromFPDFDocument(document));
- WideString str;
- if (!label.GetLabel(page_index, &str))
- return 0;
- return Utf16EncodeMaybeCopyAndReturnLength(str, buffer, buflen);
+ Optional<WideString> str = label.GetLabel(page_index);
+ return str.has_value()
+ ? Utf16EncodeMaybeCopyAndReturnLength(str.value(), buffer, buflen)
+ : 0;
}