Skip to content

Commit

Permalink
Fixed property core dump when empty value (or name)
Browse files Browse the repository at this point in the history
  • Loading branch information
g0orx committed Feb 16, 2021
1 parent 77e132d commit ecafa7e
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions property.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,18 @@ void loadProperties(char* filename) {
if(string[0]!='#') {
name=strtok(string,"=");
value=strtok(NULL,"\n");
property=malloc(sizeof(PROPERTY));
property->name=malloc(strlen(name)+1);
strcpy(property->name,name);
property->value=malloc(strlen(value)+1);
strcpy(property->value,value);
property->next_property=properties;
properties=property;
if(strcmp(name,"property_version")==0) {
version=atof(value);
}
if (name != NULL && value != NULL) {
property=malloc(sizeof(PROPERTY));
property->name=malloc(strlen(name)+1);
strcpy(property->name,name);
property->value=malloc(strlen(value)+1);
strcpy(property->value,value);
property->next_property=properties;
properties=property;
if(strcmp(name,"property_version")==0) {
version=atof(value);
}
}
}
}
fclose(f);
Expand Down

1 comment on commit ecafa7e

@csylvain
Copy link

@csylvain csylvain commented on ecafa7e Feb 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may i suggest empty strings (esp. for filenames) are a valid part of a properties file? named property but uninitialized/empty value

Please sign in to comment.