From d5e006dbad1a97e2c2ebbd4b00abb4ecb8646c92 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 1 Sep 2024 19:33:04 +0100 Subject: [PATCH] window_launcher: make PQINT less error-prone --- src/browser/window_launcher.cxx | 6 +++--- src/browser/window_launcher.hxx | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/browser/window_launcher.cxx b/src/browser/window_launcher.cxx index 9d1d048..c1cbe8f 100644 --- a/src/browser/window_launcher.cxx +++ b/src/browser/window_launcher.cxx @@ -355,7 +355,7 @@ CefRefPtr Browser::Launcher::GetResourceRequestHandle bool has_main = false; uint64_t client; bool has_client = false; - bool client_valid = true; + bool client_valid = false; this->ParseQuery(query, [&](const std::string_view& key, const std::string_view& val) { PQCHECK(id) PQCHECK(path) @@ -386,10 +386,10 @@ CefRefPtr Browser::Launcher::GetResourceRequestHandle #if defined(BOLT_PLUGINS) uint64_t client; bool has_client = false; - bool client_valid = true; + bool client_valid = false; uint64_t uid; bool has_uid = false; - bool uid_valid = true; + bool uid_valid = false; this->ParseQuery(query, [&](const std::string_view& key, const std::string_view& val) { PQINT(client) PQINT(uid) diff --git a/src/browser/window_launcher.hxx b/src/browser/window_launcher.hxx index f11401c..b5df63a 100644 --- a/src/browser/window_launcher.hxx +++ b/src/browser/window_launcher.hxx @@ -98,14 +98,16 @@ if (key == #KEY) { \ #define PQINT(KEY) \ if (key == #KEY) { \ has_##KEY = true; \ + KEY##_valid = true; \ KEY = 0; \ for (auto it = val.begin(); it != val.end(); it += 1) { \ if (*it < '0' || *it > '9') { \ KEY##_valid = false; \ - break; \ + return; \ } \ KEY = (KEY * 10) + (*it - '0'); \ } \ + return; \ } #define PQBOOL(KEY) \