mirror of
https://gitee.com/openharmony/window_window_manager
synced 2024-11-23 06:50:40 +00:00
!1150 修复config配置项为空时crash的问题
Merge pull request !1150 from 王良江/br_wlj_fix_config
This commit is contained in:
commit
03414a9e62
@ -278,6 +278,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;
|
||||
@ -288,6 +291,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)) {
|
||||
|
Loading…
Reference in New Issue
Block a user