From 2bff5f3d49748d2b7d7deffc70ca3c2d1c95b5fe Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Thu, 3 Dec 2020 23:48:35 +0000 Subject: sys-fs/hfsutils: fix tcl allocator usage in tests Tests used Tcl_Alloc() / malloc() and Tcl_Free() / free() interchangeably. Nowadays TCL allocator now requires correct alloc/free functions to be used. The patch fixes all the test crashes for me on amd64. Reported-by: Roy Bamford Closes: https://bugs.gentoo.org/757924 Package-Manager: Portage-3.0.11, Repoman-3.0.2 Signed-off-by: Sergei Trofimovich --- .../files/hfsutils-3.2.6-test-tcl-8.6.patch | 62 ++++++++++++++++++++++ sys-fs/hfsutils/hfsutils-3.2.6_p14.ebuild | 6 +++ 2 files changed, 68 insertions(+) create mode 100644 sys-fs/hfsutils/files/hfsutils-3.2.6-test-tcl-8.6.patch (limited to 'sys-fs/hfsutils') diff --git a/sys-fs/hfsutils/files/hfsutils-3.2.6-test-tcl-8.6.patch b/sys-fs/hfsutils/files/hfsutils-3.2.6-test-tcl-8.6.patch new file mode 100644 index 000000000000..fc2a5542ce40 --- /dev/null +++ b/sys-fs/hfsutils/files/hfsutils-3.2.6-test-tcl-8.6.patch @@ -0,0 +1,62 @@ +Use Tcl_Free() for arguments allocated with Tcl_SplitList(). +Use Tcl_Alloc() for arguments passed to tcl to be freed by TCL_DYNAMIC. + +https://bugs.gentoo.org/757924 +--- a/tclhfs.c ++++ b/tclhfs.c +@@ -1313,7 +1313,7 @@ int cmd_hfs(ClientData clientData, Tcl_Interp *interp, + badblocks = ALLOCX(unsigned long, listc); + if (listc && badblocks == 0) + { +- free(listv); ++ Tcl_Free((char *) listv); + + interp->result = "out of memory"; + return TCL_ERROR; +@@ -1324,13 +1324,13 @@ int cmd_hfs(ClientData clientData, Tcl_Interp *interp, + if (Tcl_ExprLong(interp, listv[i], + (long *) &badblocks[i]) != TCL_OK) + { +- free(listv); ++ Tcl_Free((char *) listv); + FREE(badblocks); + return TCL_ERROR; + } + } + +- free(listv); ++ Tcl_Free((char *) listv); + + if (do_format(argv[2], partno, 0, argv[4], listc, badblocks) == -1) + { +--- a/tclhfs.c ++++ b/tclhfs.c +@@ -378,7 +378,7 @@ int file_cmd(ClientData clientData, Tcl_Interp *interp, + return TCL_ERROR; + } + +- mem = ALLOC(char, bytes + 1); ++ mem = Tcl_Alloc(bytes + 1); + if (mem == 0) + { + interp->result = "out of memory"; +--- a/tclhfs.c ++++ b/tclhfs.c +@@ -902,7 +902,7 @@ int vol_cmd(ClientData clientData, Tcl_Interp *interp, + } + + result = Tcl_Merge(listc, listv); +- free(listv); ++ Tcl_Free((char *)listv); + + Tcl_SetResult(interp, result, TCL_DYNAMIC); + } +@@ -1038,7 +1038,7 @@ int vol_cmd(ClientData clientData, Tcl_Interp *interp, + return TCL_ERROR; + + fargv = hfs_glob(vol, listc, listv, &fargc); +- free(listv); ++ Tcl_Free((char*)listv); + + if (fargv == 0) + { diff --git a/sys-fs/hfsutils/hfsutils-3.2.6_p14.ebuild b/sys-fs/hfsutils/hfsutils-3.2.6_p14.ebuild index d6ec2af91798..5df159088c92 100644 --- a/sys-fs/hfsutils/hfsutils-3.2.6_p14.ebuild +++ b/sys-fs/hfsutils/hfsutils-3.2.6_p14.ebuild @@ -32,6 +32,7 @@ REQUIRED_USE="tk? ( tcl )" PATCHES=( "${FILESDIR}"/largerthan2gb.patch "${FILESDIR}"/${P/_p*}-fix-tcl-8.6.patch + "${FILESDIR}"/${PN}-3.2.6-test-tcl-8.6.patch ) S=${WORKDIR}/${P/_p*} @@ -57,6 +58,11 @@ src_compile() { emake CC="$(tc-getCC)" -C hfsck } +src_test() { + # Tests reuse the same image name. Let's serialize. + emake check -j1 +} + src_install() { dodir /usr/bin /usr/lib /usr/share/man/man1 emake \ -- cgit v1.2.3-65-gdbad