Bug#1052661: drkonqi: drop deallocation size mismatch to support hardened_malloc
Package: drkonqi
Version: 5.27.8-1
Severity: important
Tags: patch
Currently drkonqi crashes while running with hardened_malloc[1], due
to a deallocation size mismatch.
The memory returned by sd_journal_get_cursor(3) is free'd via
std::default_delete<char>::operator() instead of free(3).
Please consider applying the attached patch.
[1]: https://github.com/GrapheneOS/hardened_malloc/
diff -Nru orig/drkonqi-5.27.8/src/coredump/memory.h
deb/drkonqi-5.27.8/src/coredump/memory.h
--- orig/drkonqi-5.27.8/src/coredump/memory.h 2023-09-12
12:30:22.000000000 +0200
+++ deb/drkonqi-5.27.8/src/coredump/memory.h 2023-09-25
21:53:02.571084346 +0200
@@ -19,11 +19,11 @@
};
} // namespace std
-template<typename T>
+template<typename T, typename U = std::default_delete<T>>
struct Expected {
const int ret; // return value of call
const int error; // errno immediately after the call
- std::unique_ptr<T> value; // the newly owned object (may be null)
+ std::unique_ptr<T, U> value; // the newly owned object (may be null)
};
// Wrapper around C double pointer API of which we must take ownership.
@@ -38,9 +38,9 @@
// Same as owning_ptr_call but for (sd_journal *, foo **, ...) API
template<typename T, typename Func, typename... Args>
-Expected<T> contextual_owning_ptr_call(Func func, sd_journal
*context, Args &&...args)
+Expected<T, decltype(::free)*> contextual_owning_ptr_call(Func func,
sd_journal *context, Args &&...args)
{
T *raw = nullptr;
const int ret = func(context, &raw, std::forward<Args>(args)...);
- return {ret, errno, std::unique_ptr<T>(raw)};
+ return {ret, errno, std::unique_ptr<T, decltype(::free)*>(raw, ::free)};
}
Reply to: