util: Fix memleaks in error paths

This commit is contained in:
Priit Laes 2012-10-26 20:01:28 +03:00 committed by Daniel Beer
parent b91614b0d1
commit c118a684b4
1 changed files with 2 additions and 0 deletions

View File

@ -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);
if (!pb->mab) {
free(pb->current_ua);
free(pb);
return NULL;
}
@ -50,6 +51,7 @@ powerbuf_t powerbuf_new(unsigned int max_samples, unsigned int interval_us)
if (!pb->sorted) {
free(pb->current_ua);
free(pb->mab);
free(pb);
return NULL;
}