Fix potential overflow in fpc_chararray_to_shortstr for 8 bit CPU
Summary
Fix potential overflow in fpc_chararray_to_shortstr for an 8 bit CPU.
System
- Operating system: embedded
- Processor architecture: AVR
- Device: Microcontroller
What is the current bug behavior?
Converting an array of char to a shortstring leads to incorrect data being copied if the shortstring length is 255.
What is the behavior after applying this patch?
Correct conversion of array of char to shortstring
Test case
program test_shortstrings;
const
charArray: array[0..8] of char = 'charArray';
shortStr: shortstring = 'shortStr';
var
stemp: shortstring;
begin
stemp := charArray;
writeln(stemp);
writeln(shortStr);
end.
Output:
charArrashortStr
shortStr
Output after fix:
charArray
shortStr