org.sonar.l10n.delphi.rules.community-delphi.AddressOfCharacterData.html Maven / Gradle / Ivy
Why is this an issue?
Using an array index to compute the address of the first character in a string can lead to a range
check error if range checking is enabled and the string is empty. When range checking is disabled,
such an expression evaluates to nil
. In all cases except that of empty strings with
range checking enabled, casting to an untyped pointer type is equivalent.
If a non-nil pointer is required, then the result of the cast can be checked and handled
appropriately.
This is especially relevant to interactions with the WinAPI, where strings are always passed by
character pointer.
How to fix it
Cast the string to Pointer
to get the address of the first character without the
possibility of a range check error.
Resources
© 2015 - 2024 Weber Informatics LLC | Privacy Policy