Skip to content

Commit 08c4c04

Browse files
committed
Limiting potential allocation sizes
1 parent e1a7281 commit 08c4c04

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

lib/inc/sys_string/impl/platforms/emscripten_javascript.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace sysstr::util
2020
using size_type = size_t;
2121
using hash_type = unsigned;
2222

23-
static constexpr size_type max_size = std::numeric_limits<size_t>::max() / sizeof(char16_t);
23+
static constexpr size_type max_size = std::numeric_limits<ssize_t>::max() / sizeof(char16_t);
2424
};
2525

2626
template<size_t N>

lib/inc/sys_string/impl/platforms/unix_generic.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace sysstr::util
2323
using size_type = size_t;
2424
using hash_type = unsigned;
2525

26-
static constexpr size_type max_size = std::numeric_limits<size_t>::max() / sizeof(char);
26+
static constexpr size_type max_size = std::numeric_limits<ssize_t>::max() / sizeof(char);
2727
};
2828

2929
template<size_t N>

lib/inc/sys_string/impl/platforms/windows_generic.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace sysstr::util
2121
using size_type = size_t;
2222
using hash_type = unsigned;
2323

24-
static constexpr size_type max_size = std::numeric_limits<size_t>::max() / sizeof(char16_t);
24+
static constexpr size_type max_size = std::numeric_limits<ssize_t>::max() / sizeof(char16_t);
2525
};
2626

2727
template<size_t N>

lib/inc/sys_string/impl/util/generic_buffer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ namespace sysstr::util::generic
107107
static constexpr uintptr_t dynamic_flag = 0b01;
108108
using dynamic_type = dynamic_buffer<CharT, SizeT>;
109109
public:
110-
static constexpr SizeT max_size = SizeT(std::numeric_limits<SizeT>::max() - sizeof(dynamic_type)) / sizeof(CharT);
110+
static constexpr SizeT max_size = SizeT(std::numeric_limits<std::make_signed_t<SizeT>>::max() - sizeof(dynamic_type)) / sizeof(CharT);
111111
public:
112112
buffer() noexcept
113113
{

0 commit comments

Comments
 (0)