Fix segmentation fault when handler is NULL pointer

Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
Merge pull request #969 from yuyuyu101/wip-7040

Fix segmentation fault when handler is NULL pointer

Reviewed-by: Sage Weil <sage@inktank.com>