From 9af4d5e0fcf1d10e8836c5e3d80de735b4890138 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 7 Aug 2023 11:46:18 +0530 Subject: [PATCH] Fix error from asan when built with clang --- kitty/data-types.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kitty/data-types.h b/kitty/data-types.h index 3a99a6355..ad089a236 100644 --- a/kitty/data-types.h +++ b/kitty/data-types.h @@ -47,8 +47,8 @@ void log_error(const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); #define fatal(...) { log_error(__VA_ARGS__); exit(EXIT_FAILURE); } static inline void cleanup_free(void *p) { free(*(void**)p); } #define FREE_AFTER_FUNCTION __attribute__((cleanup(cleanup_free))) -static inline void cleanup_clear(void *p) { Py_XDECREF((PyObject *)p); } -#define DECREF_AFTER_FUNCTION __attribute__((cleanup(cleanup_clear))) +static inline void cleanup_decref(PyObject **p) { if(*p) { Py_DECREF(*p); *p = NULL;} } +#define DECREF_AFTER_FUNCTION __attribute__((cleanup(cleanup_decref))) #define FREE_BUFFER_AFTER_FUNCTION __attribute__((cleanup(PyBuffer_Release))) typedef unsigned long long id_type;