From: Kevin Day Date: Mon, 26 Oct 2020 04:14:10 +0000 (-0500) Subject: Update: relax parameter checks in f_utf_buffer_decrement() and f_utf_buffer_increment(). X-Git-Tag: 0.5.1~10 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=f76ffef9f13d575a3fcc0e4e4100b624e5fda6f2;p=fll Update: relax parameter checks in f_utf_buffer_decrement() and f_utf_buffer_increment(). Return F_data_not instead of an error of F_parameter. --- diff --git a/level_0/f_utf/c/utf.c b/level_0/f_utf/c/utf.c index 3f03cf8..6974518 100644 --- a/level_0/f_utf/c/utf.c +++ b/level_0/f_utf/c/utf.c @@ -9,12 +9,10 @@ extern "C" { f_return_status f_utf_buffer_decrement(const f_string_static_t buffer, f_string_range_t *range, const f_string_length_t step) { #ifndef _di_level_0_parameter_checking_ if (!range) return F_status_set_error(F_parameter); - if (range->start > range->stop) return F_status_set_error(F_parameter); - if (range->start >= buffer.used) return F_status_set_error(F_parameter); if (step < 1) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!buffer.used) return F_data_not; + if (!buffer.used || range->start > range->stop || range->start >= buffer.used) return F_data_not; f_string_length_t i = 0; uint8_t width = 0; @@ -42,12 +40,10 @@ extern "C" { f_return_status f_utf_buffer_increment(const f_string_static_t buffer, f_string_range_t *range, const f_string_length_t step) { #ifndef _di_level_0_parameter_checking_ if (!range) return F_status_set_error(F_parameter); - if (range->start > range->stop) return F_status_set_error(F_parameter); - if (range->start >= buffer.used) return F_status_set_error(F_parameter); if (step < 1) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!buffer.used) return F_data_not; + if (!buffer.used || range->start > range->stop || range->start >= buffer.used) return F_data_not; f_string_length_t i = 0; uint8_t width = 0; diff --git a/level_0/f_utf/c/utf.h b/level_0/f_utf/c/utf.h index ed6ab63..a108f3f 100644 --- a/level_0/f_utf/c/utf.h +++ b/level_0/f_utf/c/utf.h @@ -76,7 +76,7 @@ extern "C" { * F_none on success. * F_none_stop if the stop range is reached before all steps are completed. * F_none_eos if the end of buffer is reached before all steps are completed. - * F_data_not if buffer is empty. + * F_data_not if buffer is empty or out of range. * F_incomplete_utf_eos (with error bit) if the end of buffer is reached before the complete UTF-8 character can be processed. * F_parameter (with error bit) if a parameter is invalid. */ @@ -107,7 +107,7 @@ extern "C" { * F_none on success. * F_none_stop if the stop range is reached before all steps are completed. * F_none_eos if the end of buffer is reached before all steps are completed. - * F_data_not if buffer is empty. + * F_data_not if buffer is empty or out of range. * F_incomplete_utf_stop (with error bit) if the stop range is reached before the complete UTF-8 character can be processed. * F_incomplete_utf_eos (with error bit) if the end of buffer is reached before the complete UTF-8 character can be processed. * F_parameter (with error bit) if a parameter is invalid.