diff options
| author | jacqueline <me@jacqueline.id.au> | 2023-10-31 14:54:14 +1100 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2023-10-31 14:54:30 +1100 |
| commit | 2dd72320dd83a6f51c0df40d71823f8b310e4843 (patch) | |
| tree | 061f9f46dcf2b0f589f2080f9f9106a3318ace8c /src/locale/collation.cpp | |
| parent | 2ef022a2f9bac4395876ea577973c67803962b5e (diff) | |
| download | tangara-fw-2dd72320dd83a6f51c0df40d71823f8b310e4843.tar.gz | |
Don't try to treat whe whole LC_COLLATE as one big string
it would be a bad idea
Diffstat (limited to 'src/locale/collation.cpp')
| -rw-r--r-- | src/locale/collation.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/locale/collation.cpp b/src/locale/collation.cpp index 2d787b5a..31465645 100644 --- a/src/locale/collation.cpp +++ b/src/locale/collation.cpp @@ -6,7 +6,8 @@ #include "collation.hpp" -#include <stdint.h> +#include <cstdint> +#include <cstring> #include <memory> #include "esp_flash_spi_init.h" @@ -61,7 +62,8 @@ auto GLibCollator::create() -> GLibCollator* { // We reserve the first 8 bytes of the partition for an identifier / name. // Copy it out, then crop the rest of the region so that the LC_COLLATE parser // doesn't see it. - std::string name{static_cast<const char*>(region)}; + const char* region_as_str = static_cast<const char*>(region); + std::string name{region_as_str, strnlen(region_as_str, 8)}; region = static_cast<const std::byte*>(region) + 8; auto data = std::make_unique<locale_data_t>(); |
