From a941d0f173ae55a6f1076ead7ec67b6bdcf1330f Mon Sep 17 00:00:00 2001 From: NitzanMordhai Date: Tue, 19 Jul 2022 08:35:32 +0000 Subject: [PATCH] librados: rados_ioctx_destroy check for initialized ioctx If rados_ioctx_destroy called with un-initilized ioctx we will hit segmented fault checking ioctx before calling put will prevent that. Fixes: https://tracker.ceph.com/issues/55001 Signed-off-by: Nitzan Mordechai (cherry picked from commit e465cfc62ae0f982edb60291c67f4d76a71efd15) --- src/librados/librados_c.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/librados/librados_c.cc b/src/librados/librados_c.cc index 93b29911da37b..792768b9d8f96 100644 --- a/src/librados/librados_c.cc +++ b/src/librados/librados_c.cc @@ -1174,7 +1174,9 @@ extern "C" void LIBRADOS_C_API_DEFAULT_F(rados_ioctx_destroy)(rados_ioctx_t io) { tracepoint(librados, rados_ioctx_destroy_enter, io); librados::IoCtxImpl *ctx = (librados::IoCtxImpl *)io; - ctx->put(); + if (ctx) { + ctx->put(); + } tracepoint(librados, rados_ioctx_destroy_exit); } LIBRADOS_C_API_BASE_DEFAULT(rados_ioctx_destroy); -- 2.39.5