From a88e30519ec0cca46c7fc36a14556eb8c1eae0c6 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Fri, 15 Dec 2017 15:51:52 -0800 Subject: Fix some nits in FPDF_BStr_Set(). Change-Id: I298c7013541cc4ee77bef2f1e7d07984ecfa1705 Reviewed-on: https://pdfium-review.googlesource.com/21490 Reviewed-by: Ryan Harrison Commit-Queue: Lei Zhang --- fpdfsdk/fpdfview.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/fpdfsdk/fpdfview.cpp b/fpdfsdk/fpdfview.cpp index ad669614bb..aad29462cc 100644 --- a/fpdfsdk/fpdfview.cpp +++ b/fpdfsdk/fpdfview.cpp @@ -1407,19 +1407,14 @@ FPDF_EXPORT FPDF_RESULT FPDF_CALLCONV FPDF_BStr_Init(FPDF_BSTR* str) { FPDF_EXPORT FPDF_RESULT FPDF_CALLCONV FPDF_BStr_Set(FPDF_BSTR* str, FPDF_LPCSTR bstr, int length) { - if (!str) - return -1; - if (!bstr || !length) + if (!str || !bstr || !length) return -1; + if (length == -1) length = strlen(bstr); if (length == 0) { - if (str->str) { - FX_Free(str->str); - str->str = nullptr; - } - str->len = 0; + FPDF_BStr_Clear(str); return 0; } -- cgit v1.2.3