From e48dd92fc86b55f9a8bc78366cb258b4b8c59269 Mon Sep 17 00:00:00 2001 From: flame Date: Wed, 15 May 2019 15:30:42 +0800 Subject: [PATCH] bug fix (#17392) fix secure bug --- .../tests/api/analyzer_text_classification_tester.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/paddle/fluid/inference/tests/api/analyzer_text_classification_tester.cc b/paddle/fluid/inference/tests/api/analyzer_text_classification_tester.cc index 54492dbc2..78e500b2e 100644 --- a/paddle/fluid/inference/tests/api/analyzer_text_classification_tester.cc +++ b/paddle/fluid/inference/tests/api/analyzer_text_classification_tester.cc @@ -36,6 +36,8 @@ struct DataReader { tensor.lod.front().push_back(data.size()); tensor.data.Resize(data.size() * sizeof(int64_t)); + CHECK(tensor.data.data() != nullptr); + CHECK(data.data() != nullptr); memcpy(tensor.data.data(), data.data(), data.size() * sizeof(int64_t)); tensor.shape.push_back(data.size()); tensor.shape.push_back(1); @@ -87,7 +89,12 @@ TEST(Analyzer_Text_Classification, profile) { CHECK_EQ(output.lod.size(), 0UL); LOG(INFO) << "output.dtype: " << output.dtype; std::stringstream ss; - for (int i = 0; i < 5; i++) { + int num_data = 1; + for (auto i : output.shape) { + num_data *= i; + } + + for (int i = 0; i < num_data; i++) { ss << static_cast(output.data.data())[i] << " "; } LOG(INFO) << "output.data summary: " << ss.str(); -- GitLab