mirror of
https://github.com/openharmony/windowmanager.git
synced 2026-07-19 17:08:11 -04:00
fix empty xml config bug
Signed-off-by: wlj <wangliangjiang1@huawei.com> Change-Id: Ie0dbebf764ddbe5c46caf2762dc0120d54de4cc4
This commit is contained in:
@@ -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)) {
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user