From 5b8038ec0ce9eb08fe94832b6f07f53ba552fff5 Mon Sep 17 00:00:00 2001 From: Daniel Riehm Date: Fri, 26 May 2023 09:59:36 -0400 Subject: [PATCH] Allow writing too-large integers with a warning --- arrows/klv/klv_data_format.cxx | 6 ++++-- doc/release-notes/master.txt | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/arrows/klv/klv_data_format.cxx b/arrows/klv/klv_data_format.cxx index e10cf72151..a320418ca5 100644 --- a/arrows/klv/klv_data_format.cxx +++ b/arrows/klv/klv_data_format.cxx @@ -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 ); } // ---------------------------------------------------------------------------- @@ -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 ); } // ---------------------------------------------------------------------------- diff --git a/doc/release-notes/master.txt b/doc/release-notes/master.txt index 282d126d5b..cf94b0dc99 100644 --- a/doc/release-notes/master.txt +++ b/doc/release-notes/master.txt @@ -34,5 +34,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.