paulfloyd / freebsd_valgrind

Git repo used to Upstream the FreeBSD Port of Valgrind
GNU General Public License v2.0
15 stars 4 forks source link

reallocf issues? #181

Closed paulfloyd closed 2 years ago

paulfloyd commented 2 years ago
  if (new_size <= 0) { \

new_size can't be < 0 it's size_t

and I'm not sure that realllocf frees memory if the size is zero

paulfloyd commented 2 years ago

Is there even reallocf on modern FreeBSD? I suspect it was there pre jemalloc (which was introduced with FreeBSD 7 14 years ago)

paulfloyd commented 2 years ago

commit 3f5fcd59dab99d85b61f8bcff5e1d18b9d3ff1e5 (HEAD -> master, origin/master, origin/HEAD) Author: Paul Floyd pjfloyd@wanadoo.fr Date: Fri Jun 17 13:52:45 2022 +0200

Fix a few issues with reallocf and add a FreeBSD amd64 regtest

1. new_size is size_t (unsigned) and can't be negative
2. NULL not returned when the size is 0 and the memory freed
3. set ENOMEM if the allocation fails (but this time NULL does
   get returned)