File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -101,11 +101,17 @@ class Pool {
101101 umf_result_t ret;
102102 char ret_buf[256 ] = {0 };
103103 if constexpr (std::is_same_v<T, std::string>) {
104- strncpy (ret_buf, value.c_str (), sizeof (ret_buf));
104+ strncpy (ret_buf, value.c_str (), sizeof (ret_buf) - 1 );
105+ ret_buf[sizeof (ret_buf) - 1 ] = ' \0 ' ; // Ensure null-termination
106+ ret = ctlApiFunction (name, disableContext ? nullptr : pool,
107+ (void *)ret_buf, sizeof (ret_buf));
108+ } else if constexpr (std::is_arithmetic_v<T>) {
109+ std::string value_str = std::to_string (value);
110+ strncpy (ret_buf, value_str.c_str (), sizeof (ret_buf) - 1 );
111+ ret_buf[sizeof (ret_buf) - 1 ] = ' \0 ' ; // Ensure null-termination
105112 ret = ctlApiFunction (name, disableContext ? nullptr : pool,
106113 (void *)ret_buf, sizeof (ret_buf));
107114 } else {
108- strncpy (ret_buf, value, sizeof (value));
109115 ret = ctlApiFunction (name, disableContext ? nullptr : pool, &value,
110116 sizeof (value));
111117 }
You can’t perform that action at this time.
0 commit comments