Freeing strings without clearing to NULL may potentially lead
to double-free later when freeing the tree structs.
Signed-off-by: Tomas Bzatek <tbzatek@redhat.com>
void nvme_root_set_application(nvme_root_t r, const char *a)
{
- if (r->application)
+ if (r->application) {
free(r->application);
+ r->application = NULL;
+ }
if (a)
r->application = strdup(a);
}
void nvme_subsystem_set_application(nvme_subsystem_t s, const char *a)
{
- if (s->application)
+ if (s->application) {
free(s->application);
+ s->application = NULL;
+ }
if (a)
s->application = strdup(a);
}