From fb3031c2fb51235daca589105d4bfc57c0b7d06b Mon Sep 17 00:00:00 2001 From: Uy Ha Date: Mon, 10 Mar 2025 22:01:26 +0000 Subject: [PATCH] Fix `zmq_ctx_get_ext` not setting the length of the out string --- src/ctx.cpp | 5 +++-- src/ctx.hpp | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/ctx.cpp b/src/ctx.cpp index 1515051fa6..7926710fd4 100644 --- a/src/ctx.cpp +++ b/src/ctx.cpp @@ -293,7 +293,7 @@ int zmq::ctx_t::set (int option_, const void *optval_, size_t optvallen_) return -1; } -int zmq::ctx_t::get (int option_, void *optval_, const size_t *optvallen_) +int zmq::ctx_t::get (int option_, void *optval_, size_t *optvallen_) { const bool is_int = (*optvallen_ == sizeof (int)); int *value = static_cast (optval_); @@ -607,7 +607,7 @@ int zmq::thread_ctx_t::set (int option_, const void *optval_, size_t optvallen_) int zmq::thread_ctx_t::get (int option_, void *optval_, - const size_t *optvallen_) + size_t *optvallen_) { const bool is_int = (*optvallen_ == sizeof (int)); int *value = static_cast (optval_); @@ -630,6 +630,7 @@ int zmq::thread_ctx_t::get (int option_, scoped_lock_t locker (_opt_sync); memcpy (optval_, _thread_name_prefix.data (), _thread_name_prefix.size ()); + *optvallen_ = _thread_name_prefix.size (); return 0; } break; diff --git a/src/ctx.hpp b/src/ctx.hpp index 2000f99051..b6634d4f3e 100644 --- a/src/ctx.hpp +++ b/src/ctx.hpp @@ -46,7 +46,7 @@ class thread_ctx_t const char *name_ = NULL) const; int set (int option_, const void *optval_, size_t optvallen_); - int get (int option_, void *optval_, const size_t *optvallen_); + int get (int option_, void *optval_, size_t *optvallen_); protected: // Synchronisation of access to context options. @@ -89,7 +89,7 @@ class ctx_t ZMQ_FINAL : public thread_ctx_t // Set and get context properties. int set (int option_, const void *optval_, size_t optvallen_); - int get (int option_, void *optval_, const size_t *optvallen_); + int get (int option_, void *optval_, size_t *optvallen_); int get (int option_); // Create and destroy a socket.