From 26bcb362f46daaef6f564e6d10c0f2439098ed91 Mon Sep 17 00:00:00 2001 From: Brad Hubbard Date: Mon, 14 Sep 2015 16:00:43 +1000 Subject: [PATCH] Examples: hello_world.cc, content displayed after read is not null terminated. Copy contents of bufferlist to a string before sending to stdout since a bufferlist is not null terminated. Fixes: #7822 Signed-off-by: Brad Hubbard --- examples/librados/hello_world.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/librados/hello_world.cc b/examples/librados/hello_world.cc index cb5476ffc842..9d3713495a3b 100644 --- a/examples/librados/hello_world.cc +++ b/examples/librados/hello_world.cc @@ -173,7 +173,9 @@ int main(int argc, const char **argv) } else { std::cout << "we read our object " << object_name << ", and got back " << ret << " bytes with contents\n" - << read_buf.c_str() << std::endl; + std::string read_string; + read_buf.copy(0, ret, read_string); + std::cout << read_string << std::endl; } } -- 2.47.3