Skip to content

Commit

Permalink
[mio-circle] Add guards
Browse files Browse the repository at this point in the history
This will revise buffer_info() methods with assertion check and guards.

ONE-DCO-1.0-Signed-off-by: SaeHie Park <[email protected]>
  • Loading branch information
seanshpark committed Aug 26, 2024
1 parent e8f73f8 commit 7d1cb81
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion compiler/mio-circle08/src/Reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ size_t Reader::buffer_info(uint32_t buf_idx, const uint8_t **buff_data)

if (auto *buffer = (*_buffers)[buf_idx])
{
assert(buffer->offset() == 0);

if (auto *array = buffer->data())
{
if (size_t size = array->size())
Expand Down Expand Up @@ -118,7 +120,10 @@ size_t Reader::buffer_info(uint32_t buf_idx, const uint8_t **buff_data, bool &ex
return 0;

ext_offset = true;
*buff_data = reinterpret_cast<const uint8_t *>(&_rawdata->at(buffer_offset));
if (buff_data != nullptr)
{
*buff_data = reinterpret_cast<const uint8_t *>(&_rawdata->at(buffer_offset));
}
return buffer->size();
}
else if (auto *array = buffer->data())
Expand Down

0 comments on commit 7d1cb81

Please sign in to comment.