Closed guidovranken closed 10 months ago
Yes. But the only problem is that the parse_input
returns modified input. I would propose modifying the parse_input
function so it will return the flag as well:
#[cfg(feature = "error_refund")]
let (flag, refund_address, mut input) = parse_input(input)?;
#[cfg(not(feature = "error_refund"))]
let (flag, mut input) = parse_input(input)?;
@aleksuss Yes, that is what I suggested above. My worry about complexity is because of the conditional compilation you would need to change both versions of the parse_input
function (duplicating the flag assignment logic). It's not a big deal to duplicate that one line, and I agree it's nicer to encapsulate all the input handling into one function (even if there are two different versions of that function). So I think I agree with you that it's the better solution overall.
On the other hand, even if we get the default value for the flag, we will fail later because we don't pass the validation. So, I guess it's absolutely fine and could be merged.
Description
If
input
is empty a panic occurs. This PR setsflag
to the default value in that case.Performance / NEAR gas cost considerations
Testing
Fuzzing.
How should this be reviewed
Ensure that
flag
assuming the default value ifinput
is empty is the intended behavior.Additional information