Subject: | Don't call free() in do_uuid (UUID-0.18) |
The free() call in https://metacpan.org/source/JRM/UUID-0.18/UUID.xs#L277 looks wrong. str is created on the stack, so free() should not be called here. Actually this is causing segmentation faults when running the test suite on a freebsd system:
$ valgrind /usr/perl5.20.0/bin/perl -Mblib test.pl
...
==80158== Invalid free() / delete / delete[] / realloc()
==80158== at 0x117CEDE: free (in /usr/local/lib/valgrind/vgpreload_memcheck-amd64-freebsd.so)
==80158== by 0x27359F3: do_uuid (in /usr/home/eserte/.cpan/build/UUID-0.18-7xMhjb/blib/arch/auto/UUID/UUID.so)
==80158== by 0x2735A79: XS_UUID_uuid (in /usr/home/eserte/.cpan/build/UUID-0.18-7xMhjb/blib/arch/auto/UUID/UUID.so)
==80158== by 0x4A6CEE: Perl_pp_entersub (in /usr/perl5.20.0/bin/perl)
==80158== by 0x4A2852: Perl_runops_standard (in /usr/perl5.20.0/bin/perl)
==80158== by 0x43C4B6: perl_run (in /usr/perl5.20.0/bin/perl)
==80158== by 0x420F85: main (in /usr/perl5.20.0/bin/perl)
==80158== Address 0x7ff000540 is on thread 1's stack
==80158==