fixed: some issues pointed out by valgrind

SPLIT ME
[addons] sync with repo
Merge pull request #5051 from FernetMenta/valgrind

fixed: some issues pointed out by valgrind