From edfc7d1bc8723df59f107219e7f1118c557cd590 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Wed, 24 Jun 2020 00:14:04 -0500 Subject: [PATCH] Bugfix: conversion needs to properly handle '0x' and similar Invalid Parameter happens when there is no following number after the x in '0x'. This is because the start and stop range were not being checked after applying the offset. --- level_0/f_conversion/c/conversion.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/level_0/f_conversion/c/conversion.c b/level_0/f_conversion/c/conversion.c index 963abe9..7b9cf51 100644 --- a/level_0/f_conversion/c/conversion.c +++ b/level_0/f_conversion/c/conversion.c @@ -910,8 +910,7 @@ extern "C" { #ifndef _di_level_0_parameter_checking_ if (string == 0) return F_status_set_error(F_parameter); if (number == 0) return F_status_set_error(F_parameter); - if (range.start < 0) return F_status_set_error(F_parameter); - if (range.stop < range.start) return F_status_set_error(F_parameter); + if (range.start > range.stop) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (string[0] == 0) { @@ -1022,6 +1021,10 @@ extern "C" { location_offset.start = range.start + offset; location_offset.stop = range.stop; + if (range.start + offset > range.stop) { + return F_status_set_error(F_number); + } + if (mode == 10) { status = f_conversion_string_to_decimal_unsigned(string, number, location_offset); } -- 1.8.3.1