The SpanFeltTryIntoByteArray implementation in the starknet/src/byte_array_extra.cairo contract is responsible for converting a span of felt252 elements into a ByteArray. This function is crucial for handling multiple felt252 elements and converting them into a single ByteArray representation. However, the function does not handle deserialization errors properly. If deserialization fails, the function does not return Option::None, which can lead to unexpected behavior or runtime errors.
The improper handling of deserialization errors can lead to unexpected behavior or runtime errors. Specifically, if deserialization fails, the function does not return Option::None, which can lead to incorrect ByteArray objects being created. This can affect any downstream logic relying on accurate conversions.
Manual review
The deserialization logic should be updated to handle deserialization errors properly. The following code provides a corrected implementation:
This fix ensures that deserialization errors are properly handled and the function returns Option::None if deserialization fails.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.