Skip to content

Commit

Permalink
Merge pull request #1782 from daniel-riehm/dev/klv-too-large-int-warning
Browse files Browse the repository at this point in the history
Allow writing too-large integers with a warning
  • Loading branch information
daniel-riehm authored Jun 21, 2023
2 parents 1994b83 + 5b8038e commit 7435252
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 4 additions & 2 deletions arrows/klv/klv_data_format.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,8 @@ size_t
klv_uint_format
::length_of_typed( uint64_t const& value ) const
{
return m_length_constraints.fixed_or( klv_int_length( value ) );
auto const int_length = klv_int_length( value );
return std::max( m_length_constraints.fixed_or( 1 ), int_length );
}

// ----------------------------------------------------------------------------
Expand Down Expand Up @@ -277,7 +278,8 @@ size_t
klv_sint_format
::length_of_typed( int64_t const& value ) const
{
return m_length_constraints.fixed_or( klv_int_length( value ) );
auto const int_length = klv_int_length( value );
return std::max( m_length_constraints.fixed_or( 1 ), int_length );
}

// ----------------------------------------------------------------------------
Expand Down
5 changes: 3 additions & 2 deletions doc/release-notes/master.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@ Arrows: KLV

* Implemented metadata_map_io_csv.load_().

* Modified flint/IMAP behavior to print a warning when writing values with
incorrect lengths instead of correcting the length and possibly losing data.
* Modified flint, IMAP, and integer behavior to print a warning when writing
values with incorrect lengths instead of correcting the length and possibly
losing data.

0 comments on commit 7435252

Please sign in to comment.