diff options
-rw-r--r-- | src/librbd/librbd.cc | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/librbd/librbd.cc b/src/librbd/librbd.cc index 9513e1e5f2c..89bbe595752 100644 --- a/src/librbd/librbd.cc +++ b/src/librbd/librbd.cc @@ -692,7 +692,8 @@ extern "C" int rbd_open(rados_ioctx_t p, const char *name, rbd_image_t *image, librbd::ImageCtx *ictx = new librbd::ImageCtx(name, "", snap_name, io_ctx, false); int r = librbd::open_image(ictx); - *image = (rbd_image_t)ictx; + if (r >= 0) + *image = (rbd_image_t)ictx; return r; } @@ -704,7 +705,8 @@ extern "C" int rbd_open_read_only(rados_ioctx_t p, const char *name, librbd::ImageCtx *ictx = new librbd::ImageCtx(name, "", snap_name, io_ctx, true); int r = librbd::open_image(ictx); - *image = (rbd_image_t)ictx; + if (r >= 0) + *image = (rbd_image_t)ictx; return r; } |