t55_strcat_overflow.pas 782 B

1234567891011121314151617181920
  1. { t55_strcat_overflow: concatenating past the maximum is a RUNTIME error.
  2. A `string' is string[255] - a length byte and 255 characters - so the scratch
  3. a concatenation writes into cannot hold more than 255. Reading 128
  4. characters and then doing `s := s + s' asks for 256. TP3's xconcat raises
  5. "string too long" (error 16) instead of truncating, and this runtime leaves
  6. through INT 21h AH=4Ch with AL=16.
  7. `after' must NOT appear: the error path leaves the program, it does not set a
  8. flag, truncate, and carry on. The .out pins where it stopped and the .exit
  9. file pins WHY - exit 16, not the 0 progend would give. }
  10. program t55_strcat_overflow (input, output);
  11. var
  12. s : string;
  13. begin
  14. readln (s);
  15. writeln ('read');
  16. s := s + s;
  17. writeln ('after')
  18. end.