From 62bd0e78efb4962e97e51fd8bd1ab30411124c46 Mon Sep 17 00:00:00 2001 From: VirtualDeep <75492585+VirtualDeep@users.noreply.github.com> Date: Mon, 13 May 2024 15:53:09 +0300 Subject: [PATCH] generic_string: handle empty strings correctly --- include/cista/containers/string.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/include/cista/containers/string.h b/include/cista/containers/string.h index 73f72b4f..4b82369f 100644 --- a/include/cista/containers/string.h +++ b/include/cista/containers/string.h @@ -349,8 +349,11 @@ struct generic_string { if (size_s > size()) { return false; } + if (size_s == 0) { + return true; + } if (empty()) { - return size_s == 0; + return false; } return !std::memcmp(s, data(), size_s); } @@ -374,8 +377,11 @@ struct generic_string { if (size_s > size()) { return false; } + if (size_s == 0) { + return true; + } if (empty()) { - return size_s == 0; + return false; } return !std::memcmp(s, data() + size() - size_s, size_s); }