Skip to content

Commit

Permalink
Merge pull request #7 from QRPp/barometer_fromjson-mem-leak
Browse files Browse the repository at this point in the history
Fix mgos_homeassistant_barometer_fromjson() leak (#1)
  • Loading branch information
QRPp authored Sep 4, 2021
2 parents 470e1ed + 315879a commit 43bc847
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/mgos_homeassistant_barometer.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ static void barometer_pre_remove_cb(struct mgos_homeassistant_object *o) {
if (!(d = (struct mgos_homeassistant_barometer *) o->user_data)) return;
mgos_clear_timer(d->timer);
if (d->dev) mgos_barometer_destroy(&d->dev);
if (d) free(d);
free(d);
o->user_data = NULL;
}

Expand Down Expand Up @@ -146,6 +146,7 @@ bool mgos_homeassistant_barometer_fromjson(struct mgos_homeassistant *ha, struct
exit:
if (name) free(name);
if (type) free(type);
if (!ret && !o && d) free(d);
if (!ret && o) mgos_homeassistant_object_remove(&o);
return ret;
}
Expand Down

0 comments on commit 43bc847

Please sign in to comment.