From: NitzanMordhai Date: Tue, 19 Jul 2022 08:35:32 +0000 (+0000) Subject: librados: rados_ioctx_destroy check for initialized ioctx X-Git-Tag: v16.2.11~374^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F47451%2Fhead;p=ceph.git 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) --- diff --git a/src/librados/librados_c.cc b/src/librados/librados_c.cc index ca8f7c3c4890..d3090c064ac5 100644 --- a/src/librados/librados_c.cc +++ b/src/librados/librados_c.cc @@ -1157,7 +1157,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);