In platforms with bounds-checking enabled, placeholder values for array sizes in structs that may be exceeded always result in a sigtrap.
This patch updates the following classes to use flexible arrays at the end of structs:
- database
- Label
- PropertyRecord (union of three flexible arrays and a pointer*)
- cellUE
- extflat
- HierName
- EFAttr
- Dev
- utils
- HashEntry (union of two flexible arrays and a pointer*)
- internalUndoEvent: Was a plain int, replaced with a flexible char array
Additionally, the database struct editUE, which would have just a single flexible-array member, was removed and simply replaced with a character pointer.
Where possible, allocation size macros have been introduced.
---
* It is noted flexible-length arrays as part of unions are not part of the C language spec and are a GNU99 extension, however, it is supported by both GCC and Clang.
Fix code scanning alert no. 120: Wrong type of arguments to formatting function (#17)
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Fix code scanning alert no. 117: Wrong type of arguments to formatting function (#16)
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
This commit makes the code (mostly) C99-compatible, enabling to compile
it without the -Wno-error=implicit-function-declaration flag. This
way, Magic becomes usable on arm64 architectures, specifically on Apple
computers with M1/M2 SoC.