From 698b33fccebbd1cb4094fdf8dc681108824530f5 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 29 Mar 2012 12:25:09 +0200 Subject: Properly detach when the modified object is a sub object The clone() method didn't detach if we had enough memory allocated, but didn't consider that the object being modified is not the root object of the binary blob. Change-Id: I9a479ae1c873b7fe9cff7e13c539e7a41961bf68 Reviewed-by: Cristiano di Flora Reviewed-by: abcd Reviewed-by: Jamey Hicks --- src/corelib/json/qjson_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib/json/qjson_p.h') diff --git a/src/corelib/json/qjson_p.h b/src/corelib/json/qjson_p.h index f8f41c2e25..831774e456 100644 --- a/src/corelib/json/qjson_p.h +++ b/src/corelib/json/qjson_p.h @@ -745,7 +745,7 @@ public: Data *clone(Base *b, int reserve = 0) { int size = sizeof(Header) + b->size; - if (ref.load() == 1 && alloc >= size + reserve) + if (b == header->root() && ref.load() == 1 && alloc >= size + reserve) return this; if (reserve) { -- cgit v1.2.3