nim-libbacktrace/libbacktrace
Etan Kissling 5578031344
Pass length explicitly instead of relying on NULL terminators (#44)
The `getDebuggingInfo` function relies on `programCounters` being a
NULL terminated list. However, none of the usage actually adds NULL...

- In the path that passes `getProgramCounters` result into
  `getDebuggingInfo`, no explicit 0 value is added to `result`.
  In practice, there happens to be a 0 there very frequently,
  but it is not guaranteed (`env MallocScribble=1`), and even
  if it is not there the implementation often continues to work
  when processing the extra garbage data, silencing the problem.

- In the path from Nim `addDebuggingInfo` (`system/stacktraces.nim`),
  the `programCounters` list is constructed by Nim logic and also
  does not add a 0 value to the list. This means that even if we fix
  `getProgramCounters` to produce NULL terminated list, other usage
  is still broken, and outside the control of this library.

Therefore, remove the NULL terminator logic and pass length explicitly
while retaining any early loop exits when encountering 0 for compat.

Also fix some memory leaks in error conditions.
2024-07-18 17:55:27 +02:00
..
wrapper.nim Pass length explicitly instead of relying on NULL terminators (#44) 2024-07-18 17:55:27 +02:00