Skip to content

Commit

Permalink
Merge branch 'master' into fixSamples20230801
Browse files Browse the repository at this point in the history
  • Loading branch information
Leonid Terenin committed Nov 5, 2024
2 parents 5a52174 + abbed72 commit e12e58a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/mujinjson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,13 @@ void ParseJsonFile(rapidjson::Document& d, const char* filename, Container& buff
size_t nTotalToRead = nBufferSize - nFileSize;
if( nTotalToRead < nChunkSize ) {
nBufferSize += nChunkSize;
pbuffer = (char*)::realloc(pbuffer, nBufferSize);
if( !pbuffer ) {
char* maybeNull = (char*)::realloc(pbuffer, nBufferSize);
if( !maybeNull ) {
::close(fd);
::free(pbuffer);
throw MujinJSONException("Could not allocate memory");
}
pbuffer = maybeNull;
nTotalToRead = nBufferSize - nFileSize;
}
ssize_t count = ::read(fd, pbuffer + nFileSize, nBufferSize - nFileSize);
Expand Down

0 comments on commit e12e58a

Please sign in to comment.