fix empty xml config bug

Signed-off-by: wlj <wangliangjiang1@huawei.com>
Change-Id: Ie0dbebf764ddbe5c46caf2762dc0120d54de4cc4
This commit is contained in:
wlj
2022-07-08 16:14:13 +08:00
parent 284775fe66
commit 537672d43a
2 changed files with 14 additions and 0 deletions
+6
View File
@@ -277,6 +277,9 @@ public:
static inline bool IsNumber(std::string str)
{
if (str.size() == 0) {
return false;
}
for (int32_t i = 0; i < static_cast<int32_t>(str.size()); i++) {
if (str.at(i) < '0' || str.at(i) > '9') {
return false;
@@ -287,6 +290,9 @@ public:
static inline bool IsFloatingNumber(std::string str)
{
if (str.size() == 0) {
return false;
}
for (int32_t i = 0; i < static_cast<int32_t>(str.size()); i++) {
if ((str.at(i) < '0' || str.at(i) > '9') &&
(str.at(i) != '.' || std::count(str.begin(), str.end(), '.') > 1)) {
+8
View File
@@ -123,6 +123,10 @@ void WindowManagerConfig::ReadIntNumbersConfigInfo(const xmlNodePtr& currNode)
std::vector<int> numbersVec;
std::string numbersStr = reinterpret_cast<const char*>(context);
if (numbersStr.size() == 0) {
xmlFree(context);
return;
}
auto numbers = WindowHelper::Split(numbersStr, " ");
for (auto& num : numbers) {
if (!WindowHelper::IsNumber(num)) {
@@ -149,6 +153,10 @@ void WindowManagerConfig::ReadFloatNumbersConfigInfo(const xmlNodePtr& currNode)
std::vector<float> numbersVec;
std::string numbersStr = reinterpret_cast<const char*>(context);
if (numbersStr.size() == 0) {
xmlFree(context);
return;
}
auto numbers = WindowHelper::Split(numbersStr, " ");
for (auto& num : numbers) {
if (!WindowHelper::IsFloatingNumber(num)) {