Merge pull request #8620 from davidhorstmann-arm/fix-selftest-doublefree-2.28

[Backport 2.28] Fix potential double-free in calloc selftest