Skip to content

Commit

Permalink
various: fix memory leaks
Browse files Browse the repository at this point in the history
Closes: #41
  • Loading branch information
illiliti committed Oct 8, 2021
1 parent caaa021 commit 7265d30
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions udev_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -546,12 +546,14 @@ struct udev_device *udev_device_new_from_syspath(struct udev *udev, const char *
}

if (!realpath(syspath, path)) {
free(subsystem);
return NULL;
}

udev_device = calloc(1, sizeof(*udev_device));

if (!udev_device) {
free(subsystem);
return NULL;
}

Expand Down
3 changes: 3 additions & 0 deletions udev_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,16 @@ struct udev_list_entry *udev_list_entry_add(struct udev_list_entry *list_entry,
list_entry2->name = strdup(name);

if (!list_entry2->name) {
free(list_entry2);
return NULL;
}

if (value) {
list_entry2->value = strdup(value);

if (!list_entry2->value) {
free(list_entry2->name);
free(list_entry2);
return NULL;
}
}
Expand Down

0 comments on commit 7265d30

Please sign in to comment.