Also in case of allocation error we have to free existing memory before return.

This commit is contained in:
dwarning 2018-11-07 16:55:01 +01:00 committed by Holger Vogt
parent a6fa3aaa11
commit d7089adcaf
3 changed files with 5 additions and 0 deletions

View File

@ -286,6 +286,7 @@ void cm_d_osc(ARGS)
y = (double *) calloc((size_t) freq_size, sizeof(double));
if (!y) {
cm_message_send(d_osc_allocation_error);
if(x) free(x);
return;
}

View File

@ -444,6 +444,8 @@ cm_table2D(ARGS) /* structure holding parms, inputs, outputs, etc. */
cm_message_printf("Insufficient memory to read file %s", PARAM(file));
loc->state->atend = 1;
loc->init_err = 1;
if(cFile) free(cFile);
if(cThisLine) free(cThisLine);
return;
}
/* read whole file into cFile */

View File

@ -458,6 +458,8 @@ cm_table3D(ARGS) /* structure holding parms, inputs, outputs, etc. */
cm_message_printf("Insufficient memory to read file %s", PARAM(file));
loc->state->atend = 1;
loc->init_err = 1;
if(cFile) free(cFile);
if(cThisLine) free(cThisLine);
return;
}
/* read whole file into cFile */