Skip to content

Commit

Permalink
fix population filename serialisation
Browse files Browse the repository at this point in the history
  • Loading branch information
rpreen committed Nov 10, 2023
1 parent 14cd31b commit b36dd67
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion xcsf/param.c
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ size_t
param_save(const struct XCSF *xcsf, FILE *fp)
{
size_t s = 0;
size_t len = strnlen(xcsf->population_file, MAX_LEN);
size_t len = strnlen(xcsf->population_file, MAX_LEN) + 1;
s += fwrite(&len, sizeof(size_t), 1, fp);
s += fwrite(xcsf->population_file, sizeof(char), len, fp);
s += fwrite(&xcsf->time, sizeof(int), 1, fp);
Expand Down Expand Up @@ -535,6 +535,10 @@ param_load(struct XCSF *xcsf, FILE *fp)
size_t s = 0;
size_t len = 0;
s += fread(&len, sizeof(size_t), 1, fp);
if (len < 1) {
printf("param_load(): error len < 1\n");
exit(EXIT_FAILURE);

Check warning on line 540 in xcsf/param.c

View check run for this annotation

Codecov / codecov/patch

xcsf/param.c#L539-L540

Added lines #L539 - L540 were not covered by tests
}
free(xcsf->population_file);
xcsf->population_file = malloc(sizeof(char) * len);
s += fread(xcsf->population_file, sizeof(char), len, fp);
Expand Down

0 comments on commit b36dd67

Please sign in to comment.