Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/cobhan_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class CobhanBuffer {
explicit CobhanBuffer(size_t data_len_bytes) {
if (data_len_bytes > max_int32_size) {
throw std::invalid_argument(
"Requested data length exceeds maximum allowable size");
"CobhanBuffer(size_t): Requested data length exceeds maximum allowable size (2GB limit)");
}
allocation_size = DataSizeToAllocationSize(data_len_bytes);
cbuffer = new char[allocation_size];
Expand All @@ -37,7 +37,7 @@ class CobhanBuffer {
: cbuffer(cbuffer), allocation_size(allocation_size), ownership(false) {
if (allocation_size > max_int32_size) {
throw std::invalid_argument(
"Allocation size exceeds maximum allowable size");
"CobhanBuffer(char*, size_t): Allocation size exceeds maximum allowable size (2GB limit)");
}
initialize();
}
Expand Down Expand Up @@ -114,7 +114,7 @@ class CobhanBuffer {
+ safety_padding_bytes; // Add safety padding if configured
if (allocation > max_int32_size) {
throw std::invalid_argument(
"Calculated allocation size exceeds maximum allowable size");
"CobhanBuffer::DataSizeToAllocationSize: Calculated allocation size exceeds maximum allowable size (2GB limit)");
}
return allocation;
}
Expand All @@ -130,7 +130,7 @@ class CobhanBuffer {
canary_size_bytes - safety_padding_bytes;
if (data_len_bytes > max_int32_size) {
throw std::invalid_argument(
"Calculated data size exceeds maximum allowable size");
"CobhanBuffer::AllocationSizeToMaxDataSize: Calculated data size exceeds maximum allowable size (2GB limit)");
}
return data_len_bytes;
}
Expand Down Expand Up @@ -171,11 +171,11 @@ class CobhanBuffer {
void set_data_len_bytes(size_t data_len_bytes) {
if (data_len_bytes > max_int32_size) {
throw std::invalid_argument(
"Requested data length exceeds maximum allowable size");
"CobhanBuffer::set_data_len_bytes: Requested data length exceeds maximum allowable size (2GB limit)");
}
if (data_len_bytes > max_data_size) {
throw std::invalid_argument(
"Requested data length exceeds allocation size");
"CobhanBuffer::set_data_len_bytes: Requested data length exceeds buffer maximum data size");
}
*data_len_ptr = static_cast<int32_t>(data_len_bytes);
}
Expand Down Expand Up @@ -204,7 +204,7 @@ class CobhanBuffer {
}

if (data_len_bytes > max_int32_size) {
throw std::invalid_argument("Data length exceeds maximum allowable size");
throw std::invalid_argument("CobhanBuffer::initialize: Data length exceeds maximum allowable size (2GB limit)");
}

// Write Cobhan header values
Expand Down Expand Up @@ -249,7 +249,7 @@ class CobhanBuffer {
allocation_size = other.allocation_size;
if (allocation_size > max_int32_size) {
throw std::invalid_argument(
"Allocation size exceeds maximum allowable size");
"CobhanBuffer::moveFrom: Allocation size exceeds maximum allowable size (2GB limit)");
}

cbuffer = new char[allocation_size];
Expand Down
5 changes: 2 additions & 3 deletions src/cobhan_buffer_napi.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,8 @@ class CobhanBufferNapi : public CobhanBuffer {
env, get_data_ptr(), get_data_len_bytes(), &napiStr);

if (status != napi_ok) {
napi_throw_error(env, nullptr,
"Failed to create Napi::String from CobhanBuffer");
return {};
NapiUtils::ThrowException(env,
"CobhanBufferNapi::ToString: Failed to create Napi::String from CobhanBuffer");
}

return {env, napiStr};
Expand Down
Loading