Avoid segfaults for empty param string
This commit is contained in:
parent
aa8825d9d8
commit
a94c066014
@ -168,13 +168,15 @@ int eea(
|
|||||||
|
|
||||||
// params
|
// params
|
||||||
// allocate buffer for params
|
// allocate buffer for params
|
||||||
char* params=calloc(sizeof(char), strlen(params_string)+1);
|
if(params_string!=NULL) {
|
||||||
strcpy(params, params_string);
|
char* params=calloc(sizeof(char), strlen(params_string)+1);
|
||||||
remove_entry(params, "starting_time");
|
strcpy(params, params_string);
|
||||||
remove_entry(params, "init");
|
remove_entry(params, "starting_time");
|
||||||
remove_entry(params, "nsteps");
|
remove_entry(params, "init");
|
||||||
fprintf(savefile," -p \"%s;starting_time=%lu;nsteps=%lu;init=file:%s\"", params, t+1, (nsteps == 0 ? 0 : nsteps-t-1), savefile_string);
|
remove_entry(params, "nsteps");
|
||||||
free(params);
|
fprintf(savefile," -p \"%s;starting_time=%lu;nsteps=%lu;init=file:%s\"", params, t+1, (nsteps == 0 ? 0 : nsteps-t-1), savefile_string);
|
||||||
|
free(params);
|
||||||
|
}
|
||||||
|
|
||||||
fprintf(savefile," energy\n");
|
fprintf(savefile," energy\n");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user