From 0e56bd38f3123ced3de8c0c2862b7f7c55549078 Mon Sep 17 00:00:00 2001 From: MediaPipe Team Date: Wed, 11 Jan 2023 12:54:58 -0800 Subject: [PATCH] Fix for CHECK failure due to pointer description sometimes being larger than allocated string space PiperOrigin-RevId: 501355568 --- mediapipe/framework/tool/sink.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mediapipe/framework/tool/sink.cc b/mediapipe/framework/tool/sink.cc index 4a181b43f..f8abf4925 100644 --- a/mediapipe/framework/tool/sink.cc +++ b/mediapipe/framework/tool/sink.cc @@ -87,7 +87,8 @@ void AddVectorSink(const std::string& stream_name, // node->mutable_options()->MutableExtension( CallbackPacketCalculatorOptions::ext); options->set_type(CallbackPacketCalculatorOptions::VECTOR_PACKET); - char address[17]; + // Up to 64-bit pointer in hex (16 characters) and an optional "0x" prepended. + char address[19]; int written = snprintf(address, sizeof(address), "%p", dumped_data); CHECK(written > 0 && written < sizeof(address)); options->set_pointer(address); @@ -112,7 +113,8 @@ void AddPostStreamPacketSink(const std::string& stream_name, node->mutable_options()->MutableExtension( CallbackPacketCalculatorOptions::ext); options->set_type(CallbackPacketCalculatorOptions::POST_STREAM_PACKET); - char address[17]; + // Up to 64-bit pointer in hex (16 characters) and an optional "0x" prepended. + char address[19]; int written = snprintf(address, sizeof(address), "%p", post_stream_packet); CHECK(written > 0 && written < sizeof(address)); options->set_pointer(address);