These methods incorrectly delete ImageCtx on error, resulting
in double-free heap corruption.
Fixes: https://tracker.ceph.com/issues/43178
Signed-off-by: yangjun <yangjun@cmss.chinamobile.com>
ictx->id.c_str(), ictx->snap_name.c_str(), ictx->read_only);
int r = ictx->state->open(0);
- if (r < 0) {
- delete ictx;
- } else {
+ if (r >= 0) {
*image = (rbd_image_t)ictx;
}
tracepoint(librbd, open_image_exit, r);
ictx->id.c_str(), ictx->snap_name.c_str(), ictx->read_only);
int r = ictx->state->open(0);
- if (r < 0) {
- delete ictx;
- } else {
+ if (r >= 0) {
*image = (rbd_image_t)ictx;
}
tracepoint(librbd, open_image_exit, r);