Skip to content

Commit

Permalink
Simplify overflow check for layer size
Browse files Browse the repository at this point in the history
  • Loading branch information
bukka committed May 19, 2018
1 parent 8407854 commit 1df0c89
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/fann_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -540,9 +540,8 @@ struct fann *fann_create_from_fd(FILE * conf, const char *configuration_file)
/* determine how many neurons there should be in each layer */
for(layer_it = ann->first_layer; layer_it != ann->last_layer; layer_it++)
{
if(fscanf(conf, "%u ", &layer_size) != 1 ||
layer_size == 0 || layer_size > INT_MAX ||
layer_size > INT_MAX - ann->total_neurons)
if(fscanf(conf, "%u ", &layer_size) != 1
|| layer_size == 0 || layer_size > INT_MAX - ann->total_neurons)
{
fann_error((struct fann_error *) ann, FANN_E_CANT_READ_CONFIG, "layer_sizes", configuration_file);
fann_destroy(ann);
Expand Down

0 comments on commit 1df0c89

Please sign in to comment.