1# Memory Bugs 2 3This is a list of all of the memory bugs that were found in *released* versions 4of `bc`, `dc`, or `bcl`. (Non-released commits with memory bugs do not count.) 5 6I made this list for two reasons: first, so users can know what versions of 7`bc`, `dc`, and `bcl` have vulnerabilities, and two, I once had a perfect record 8and then found a couple, but forgot and claimed I still had a perfect record 9right after, which was embarrassing. 10 11This list is sorted by the first version a bug exists in, not the last it 12existed in. 13 14* In versions `1.1.0` until `6.2.0` (inclusive) of `bc` and `dc`, there is a 15 out of bounds read and write in history when pressing ctrl+r (or any other 16 unused letter) then inserting two characters. 17 18 The first version without this bug is `6.2.1`. 19 20* In versions `3.0.0` until `6.0.1` (inclusive) of `bc` and `dc`, there is a 21 double-free on `SIGINT` when using command-line expressions with `-e` and 22 `-f`. This was caused by not properly ending a jump series. 23 24 The first version without this bug is `6.0.2`. 25 26* In versions `5.0.0` until `6.0.4` (inclusive) of `bc`, there is an 27 out-of-bounds access if a non-local (non-`auto`) variable is set to a string 28 with `asciify()`, then the function is redefined with a use of the same 29 non-local variable. 30 31 This happened because strings were stored per-function, and the non-local 32 variable now had a reference to the string in the old function, which could be 33 at a higher index than exists in the new function. Strings are stored globally 34 now, and they are *not* freed once not used. 35 36 The first version without this bug is `6.1.0`. 37 38* In versions `5.0.0` until `6.0.4` (inclusive) of `bc`, there is another 39 out-of-bounds access if an array is passed to the `asciify()` built-in 40 function as the only argument. This happened because arrays are allowed as 41 function arguments, which allowed them to be used as arguments to `asciify()`, 42 but they should not have been allowed. However, since they were, the 43 `asciify()` code tried to access an argument that was not there. 44 45 The first version without this bug is `6.1.0`. 46 47* In version `6.0.0` of `bcl`, there are several uses of initialized data that 48 have the same root cause: I forgot to call `memset()` on the per-thread global 49 data. This is because the data used to be *actually* global, which meant that 50 it was initialized to zero by the system. This happened because I thought I 51 had properly hooked Valgrind into my `bcl` tests, but I had not. 52 53 The first version without this bug is `6.0.1`. 54