Skip to content

Commit 54a6f95

Browse files
committed
CCBC-1596: Fix dangling pointer in cbc-bucket-list
tools/cbc.cc:2048:28: warning: object backing the pointer will be destroyed at the end of the full-expression [-Wdangling-gsl] const char *name = json[i]["name"].asString().c_str(); ^~~~~~~~~~~~~~~~~~~~~~~~~~ tools/cbc.cc:2049:34: warning: object backing the pointer will be destroyed at the end of the full-expression [-Wdangling-gsl] const char *bucketType = json[i]["bucketType"].asString().c_str(); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Change-Id: Ife437d498e83778666f6911dafc8020a92f433a8 Reviewed-on: https://review.couchbase.org/c/libcouchbase/+/190104 Tested-by: Build Bot <build@couchbase.com> Reviewed-by: Brett Lawson <brett19@gmail.com>
1 parent 55a04cb commit 54a6f95

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

tools/cbc.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2044,11 +2044,11 @@ void BucketListHandler::format()
20442044

20452045
printf("%-20s%-10s%s\n", "Name", "Type", "Items");
20462046

2047-
for (Json::Value::ArrayIndex i = 0; i < json.size(); ++i) {
2048-
const char *name = json[i]["name"].asString().c_str();
2049-
const char *bucketType = json[i]["bucketType"].asString().c_str();
2050-
const int itemCount = json[i]["basicStats"]["itemCount"].asInt();
2051-
printf("%-20s%-10s%i\n", name, bucketType, itemCount);
2047+
for (auto &bucket : json) {
2048+
auto name = bucket["name"].asString();
2049+
auto type = bucket["bucketType"].asString();
2050+
const int itemCount = bucket["basicStats"]["itemCount"].asInt();
2051+
printf("%-20s%-10s%i\n", name.c_str(), type.c_str(), itemCount);
20522052
}
20532053
}
20542054

0 commit comments

Comments
 (0)