From ab6208e808ebe590b29af7fcc7510acc9c11cdae Mon Sep 17 00:00:00 2001 From: nihuini Date: Thu, 20 Feb 2025 16:27:50 +0800 Subject: [PATCH] w --- src/paramdict.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/paramdict.cpp b/src/paramdict.cpp index 0bbfb467824..a6a7c893c2e 100644 --- a/src/paramdict.cpp +++ b/src/paramdict.cpp @@ -372,6 +372,14 @@ int ParamDict::load_param(const DataReader& dr) d->params[id].s = std::string(vstr); } +#if NCNN_SIMPLESTL + // simple stl string has no tail zero by default, append one + int len = d->params[id].s.size(); + d->params[id].s.resize(len + 1); + d->params[id].s[len] = '\0'; + d->params[id].s.resize(len); +#endif + d->params[id].type = 7; continue; @@ -555,14 +563,13 @@ int ParamDict::load_param_bin(const DataReader& dr) tmpstr[len_padded] = '\0'; + d->params[id].s = tmpstr.data(); + #if NCNN_SIMPLESTL // simple stl string has no tail zero by default, append one d->params[id].s.resize(len + 1); - memcpy(d->params[id].s.data(), tmpstr.data(), len); d->params[id].s[len] = '\0'; d->params[id].s.resize(len); -#else - d->params[id].s = tmpstr.data(); #endif d->params[id].type = 7;