Skip to content

Commit

Permalink
Reserve extra byte in LoadDataFromFile() in case caller wants to appe…
Browse files Browse the repository at this point in the history
…nd '\0'

# Conflicts:
#	ccutil/genericvector.h
  • Loading branch information
zdenop committed Jun 5, 2018
1 parent 65e5b7a commit 23f1fb0
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ccutil/genericvector.h
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,8 @@ inline bool LoadDataFromFile(const STRING& filename,
size_t size = ftell(fp);
fseek(fp, 0, SEEK_SET);
if (size > 0) {
// reserve an extra byte in case caller wants to append a '\0' character
data->reserve(size + 1);
data->resize_no_init(size);
result = fread(&(*data)[0], 1, size, fp) == size;
}
Expand Down

0 comments on commit 23f1fb0

Please sign in to comment.