context: fix NULL dereference in ref/unref
operation: fix NULL dereference in ref/unref