From 2b3d362edbedf3ebbbeb4d50e3653c1702fd61ce Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Thu, 16 Feb 2017 11:46:31 +0100 Subject: [PATCH] libopkg: fix pkg_set_ptr() to properly set NULL pointers Signed-off-by: Jo-Philipp Wich --- libopkg/pkg.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libopkg/pkg.h b/libopkg/pkg.h index 3237f83..d9cab55 100644 --- a/libopkg/pkg.h +++ b/libopkg/pkg.h @@ -198,7 +198,8 @@ static inline char *pkg_get_string(const pkg_t *pkg, int id) static inline void * pkg_set_ptr(pkg_t *pkg, int id, void *ptr) { - return ptr ? *(void **) pkg_set_raw(pkg, id, &ptr, sizeof(ptr)) : NULL; + void **res = pkg_set_raw(pkg, id, &ptr, sizeof(ptr)); + return res ? *res : NULL; } static inline void * pkg_get_ptr(const pkg_t *pkg, int id) -- 2.30.2