wiedehopf/readsb

Double-free in 'convert.c'

Closed this issue · 0 comments

gvanem commented

Running the convert_benchmark.exe program on Windows, I got a Dr. Watson assert in cleanup_converter() since
AFAICS, the uc8_lookup pointer was already freed.

This little patch fixed it:

--- a/convert.c 2022-06-25 18:49:20
+++ b/convert.c 2023-04-29 10:54:38
@@ -496,5 +496,7 @@
     free(uc8_lookup);
 #if defined(SC16Q11_TABLE_BITS)
     free(sc16q11_lookup);
+    sc16q11_lookup = NULL;
 #endif
+    uc8_lookup = NULL;
 }

BTW1, I've not built with -DSC16Q11_TABLE_BITS. But assume it has the same issue.

BTW2, here are my results on AMD 3.8GHz (with clang-cl):

Benchmarking: SC16Q11, DC   1451.28M samples in 5.000000 seconds
  290.26M samples/second
Benchmarking: SC16Q11, no DC   2352.60M samples in 5.000000 seconds
  470.52M samples/second
Benchmarking: UC8, DC   1157.00M samples in 5.000000 seconds
  231.40M samples/second
Benchmarking: UC8, no DC   8046.42M samples in 5.000000 seconds
  1609.28M samples/second
Benchmarking: SC16, DC   1474.06M samples in 5.000000 seconds
  294.81M samples/second
Benchmarking: SC16, no DC   2413.32M samples in 5.000000 seconds
  482.66M samples/second