diff --git a/src/libs/zbxdbhigh/proxy.c b/src/libs/zbxdbhigh/proxy.c
index 4db2d420d9..37b218851a 100644
--- a/src/libs/zbxdbhigh/proxy.c
+++ b/src/libs/zbxdbhigh/proxy.c
@@ -478,7 +478,7 @@ typedef struct
 {
 	zbx_uint64_t	itemid;
 	zbx_uint64_t	master_itemid;
-	struct zbx_json	data;
+	char		*buffer;
 }
 zbx_proxy_item_config_t;
 
@@ -498,7 +498,6 @@ static int	get_proxyconfig_table_items(zbx_uint64_t proxy_hostid, struct zbx_jso
 	DB_RESULT		result;
 	DB_ROW			row;
 	zbx_hashset_t		proxy_items;
-	struct zbx_json		*jrow;
 	zbx_vector_ptr_t	items;
 	zbx_uint64_t		itemid;
 	zbx_hashset_iter_t	iter;
@@ -575,24 +574,29 @@ static int	get_proxyconfig_table_items(zbx_uint64_t proxy_hostid, struct zbx_jso
 		if (SUCCEED != DBis_null(row[fld_master]))
 		{
 			zbx_proxy_item_config_t	proxy_item_local, *proxy_item;
+			struct zbx_json		json_array;
 
 			ZBX_STR2UINT64(proxy_item_local.itemid, row[0]);
 			ZBX_STR2UINT64(proxy_item_local.master_itemid, row[fld_master]);
 			proxy_item = zbx_hashset_insert(&proxy_items, &proxy_item_local, sizeof(proxy_item_local));
-			zbx_json_initarray(&proxy_item->data, 256);
-			jrow = &proxy_item->data;
+
+			zbx_json_initarray(&json_array, 256);
+			proxyconfig_add_row(&json_array, row, table);
+			zbx_json_close(&json_array);
+			proxy_item->buffer = zbx_strdup(NULL, json_array.buffer);
+			zbx_json_free(&json_array);
 		}
 		else
 		{
 			ZBX_STR2UINT64(itemid, row[0]);
 			zbx_hashset_insert(itemids, &itemid, sizeof(itemid));
+
 			zbx_json_addarray(j, NULL);
-			jrow = j;
+			proxyconfig_add_row(j, row, table);
+			zbx_json_close(j);
 		}
-
-		proxyconfig_add_row(jrow, row, table);
-		zbx_json_close(jrow);
 	}
+	DBfree_result(result);
 
 	/* flush cached dependent items */
 
@@ -622,9 +626,9 @@ static int	get_proxyconfig_table_items(zbx_uint64_t proxy_hostid, struct zbx_jso
 			if (NULL != zbx_hashset_search(itemids, &proxy_item->master_itemid))
 			{
 				zbx_hashset_insert(itemids, &proxy_item->itemid, sizeof(itemid));
-				zbx_json_addraw(j, NULL, proxy_item->data.buffer);
+				zbx_json_addraw(j, NULL, proxy_item->buffer);
 			}
-			zbx_json_free(&proxy_item->data);
+			zbx_free(proxy_item->buffer);
 			zbx_hashset_remove_direct(&proxy_items, proxy_item);
 		}
 
@@ -632,9 +636,6 @@ static int	get_proxyconfig_table_items(zbx_uint64_t proxy_hostid, struct zbx_jso
 	}
 	zbx_vector_ptr_destroy(&items);
 	zbx_hashset_destroy(&proxy_items);
-
-	DBfree_result(result);
-
 skip_data:
 	zbx_free(sql);
 
