diff --git a/src/patchelf.cc b/src/patchelf.cc index 246496d5..4cc5e183 100644 --- a/src/patchelf.cc +++ b/src/patchelf.cc @@ -1500,7 +1500,7 @@ void ElfFile::modifyRPath(RPathOp op, debug("new rpath is '%s'\n", newRPath.c_str()); - if (newRPath.size() <= rpathSize) { + if (rpath && newRPath.size() <= rpathSize) { memcpy(rpath, newRPath.c_str(), newRPath.size() + 1); return; } diff --git a/tests/Makefile.am b/tests/Makefile.am index 38438b81..135ae4fb 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -37,7 +37,8 @@ src_TESTS = \ no-gnu-hash.sh \ no-dynamic-section.sh \ args-from-file.sh \ - basic-flags.sh + basic-flags.sh \ + set-empty-rpath.sh build_TESTS = \ $(no_rpath_arch_TESTS) diff --git a/tests/set-empty-rpath.sh b/tests/set-empty-rpath.sh new file mode 100755 index 00000000..de846a27 --- /dev/null +++ b/tests/set-empty-rpath.sh @@ -0,0 +1,11 @@ +#! /bin/sh -e +SCRATCH=scratch/$(basename $0 .sh) + +rm -rf ${SCRATCH} +mkdir -p ${SCRATCH} + +cp simple ${SCRATCH}/simple + +../src/patchelf --force-rpath --set-rpath "" ${SCRATCH}/simple + +${SCRATCH}/simple