Skip to content

Commit

Permalink
[struct_pack] fix qicosmos#207
Browse files Browse the repository at this point in the history
  • Loading branch information
poor-circle committed Feb 17, 2023
1 parent a251942 commit f6bd214
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions include/struct_pack/struct_pack/struct_pack_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1858,14 +1858,14 @@ class unpacker {
constexpr bool has_compatible =
check_if_compatible_element_exist<decltype(get_types(Type{}))>();
if constexpr (has_compatible) {
data_len = reader_.tellg();
data_len_ = reader_.tellg();
}
auto &&[err_code, buffer_len] = deserialize_metainfo<Type>();
if (err_code != struct_pack::errc{}) [[unlikely]] {
return err_code;
}
if constexpr (has_compatible) {
data_len += buffer_len;
data_len_ += buffer_len;
}
switch (size_type_) {
case 0:
Expand Down Expand Up @@ -1910,15 +1910,15 @@ class unpacker {
constexpr bool has_compatible =
check_if_compatible_element_exist<decltype(get_types(Type{}))>();
if constexpr (has_compatible) {
data_len = reader_.tellg();
data_len_ = reader_.tellg();
}
auto &&[err_code, buffer_len] = deserialize_metainfo<Type>();
len = buffer_len;
if (err_code != struct_pack::errc{}) [[unlikely]] {
return err_code;
}
if constexpr (has_compatible) {
data_len += buffer_len;
data_len_ += buffer_len;
}
switch (size_type_) {
case 0:
Expand Down Expand Up @@ -1966,15 +1966,15 @@ class unpacker {
constexpr bool has_compatible =
check_if_compatible_element_exist<decltype(get_types(Type{}))>();
if constexpr (has_compatible) {
data_len = reader_.tellg();
data_len_ = reader_.tellg();
}

auto &&[err_code, buffer_len] = deserialize_metainfo<T>();
if (err_code != struct_pack::errc{}) [[unlikely]] {
return err_code;
}
if constexpr (has_compatible) {
data_len += buffer_len;
data_len_ += buffer_len;
}
switch (size_type_) {
case 0:
Expand Down Expand Up @@ -2396,7 +2396,7 @@ class unpacker {
else if constexpr (exist_compatible_member<type, version>) {
if constexpr (id == type_id::compatible_t) {
if constexpr (version == type::version_number) {
if (reader_.tellg() >= data_len) {
if (reader_.tellg() >= data_len_) {
size_type_ = UCHAR_MAX; // Just notice that this is not a real
// error, this is a flag for exit.
return struct_pack::errc::no_buffer_space;
Expand Down Expand Up @@ -2567,7 +2567,7 @@ class unpacker {
}

public:
std::size_t data_len;
std::size_t data_len_;

private:
Reader &reader_;
Expand Down

0 comments on commit f6bd214

Please sign in to comment.