Skip to content

Commit

Permalink
w
Browse files Browse the repository at this point in the history
  • Loading branch information
nihui committed Feb 20, 2025
1 parent 14b0827 commit ab6208e
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/paramdict.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit ab6208e

Please sign in to comment.