util: Fix memleaks in error paths
This commit is contained in:
parent
b91614b0d1
commit
c118a684b4
|
@ -43,6 +43,7 @@ powerbuf_t powerbuf_new(unsigned int max_samples, unsigned int interval_us)
|
||||||
pb->mab = malloc(sizeof(pb->mab[0]) * max_samples);
|
pb->mab = malloc(sizeof(pb->mab[0]) * max_samples);
|
||||||
if (!pb->mab) {
|
if (!pb->mab) {
|
||||||
free(pb->current_ua);
|
free(pb->current_ua);
|
||||||
|
free(pb);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,6 +51,7 @@ powerbuf_t powerbuf_new(unsigned int max_samples, unsigned int interval_us)
|
||||||
if (!pb->sorted) {
|
if (!pb->sorted) {
|
||||||
free(pb->current_ua);
|
free(pb->current_ua);
|
||||||
free(pb->mab);
|
free(pb->mab);
|
||||||
|
free(pb);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue