Closed JetForMe closed 9 years ago
Note that this doesn't happen if I iterate the array like this:
for(size_t idx = 0; idx < playlist.size(); ++idx)
{
const picojson::value& v = playlist[idx];
if (!v.is<std::string>()) { continue; }
std::string track = v.get<std::string>();
LogDebug("Track %02i: %s", idx, track.c_str());
}
Also, I noticed I was getting corrupted values for a few of the strings using the iterator method, but with the index approach it seems correct.
Seems like an error in your code:
for (picojson::value::array::const_iterator trackIter = playlist.begin(); iter != playlist.end(); ++trackIter)
The condition to exit the loop should be trackIter != playlist.end()
.
Hahahahahahaa I'm such an idiot! I'm so sorry. I even looked at that line to be sure I had it right, thinking there was an issue at the end of the array. Wow. So sorry.
The following JSON causes the code below it to fail when it gets to the end of the array. Specifically, I get a bad_alloc exception (on OS X):
This happens on the line with " <===== bad_alloc" below.