From 251d00eb0e924ef6fb183e03c07122826d1c4f10 Mon Sep 17 00:00:00 2001 From: Florian Mayer Date: Wed, 22 Nov 2023 11:24:27 +0000 Subject: [PATCH] Handle empty read from file. Test: run /vendor/bin/dump/dump_power Bug: 312681873 Change-Id: I8c49cf7f0048190f02d35d50984abca361d517f1 --- dumpstate/dump_power.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dumpstate/dump_power.cpp b/dumpstate/dump_power.cpp index e334f58c..9da35450 100644 --- a/dumpstate/dump_power.cpp +++ b/dumpstate/dump_power.cpp @@ -362,7 +362,7 @@ void dumpBatteryDefend() { for (auto &file : files) { fileLocation = std::string(config[1]) + std::string(file); - if (!android::base::ReadFileToString(fileLocation, &content)) { + if (!android::base::ReadFileToString(fileLocation, &content) || content.empty()) { content = "\n"; }