From 95e6469bd2ceef92bcaaf140e2724fc73d556185 Mon Sep 17 00:00:00 2001 From: dormando Date: Tue, 27 Mar 2018 18:58:34 -0700 Subject: [PATCH] extstore: fix ref leak when using binprot GATK GATK returns a key but not the value. c->io_wraplist is only appended if the value is to be returned, but c->item is skipped if it is an ITEM_HDR at all. This now checks for the ITEM_HDR bit being set but also !value which then reclaims the reference normally. I knew doubling up the cleanup code made it a lot more complex, and hope to flatten that to a single path. Also the TOUCH/GAT/GATK binprot code has no real test coverage, nor mc-crusher entries. Should be worth fixing. --- memcached.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/memcached.c b/memcached.c index 2807cf1..d6dd990 100644 --- a/memcached.c +++ b/memcached.c @@ -1686,10 +1686,11 @@ static void process_bin_get_or_touch(conn *c) { c->write_and_go = conn_new_cmd; /* Remember this command so we can garbage collect it later */ #ifdef EXTSTORE - if ((it->it_flags & ITEM_HDR) == 0) { - c->item = it; - } else { + if ((it->it_flags & ITEM_HDR) != 0 && should_return_value) { + // Only have extstore clean if header and returning value. c->item = NULL; + } else { + c->item = it; } #else c->item = it;