Commit afca8c8e authored by Jean-Paul Saman's avatar Jean-Paul Saman

src/dvbpsi.c: Use va_end() on error path of message functions.

parent e74393dd
...@@ -527,9 +527,12 @@ void dvbpsi_message(dvbpsi_t *dvbpsi, const dvbpsi_msg_level_t level, const char ...@@ -527,9 +527,12 @@ void dvbpsi_message(dvbpsi_t *dvbpsi, const dvbpsi_msg_level_t level, const char
int err = vasprintf(&msg, fmt, ap); int err = vasprintf(&msg, fmt, ap);
#else #else
msg = malloc(DVBPSI_MSG_SIZE); msg = malloc(DVBPSI_MSG_SIZE);
if (msg == NULL) if (msg == NULL) {
va_end(ap);
return; return;
}
if (snprintf(&msg, DVBPSI_MSG_SIZE, DVBPSI_MSG_FORMAT, ap) < 0) { if (snprintf(&msg, DVBPSI_MSG_SIZE, DVBPSI_MSG_FORMAT, ap) < 0) {
va_end(ap);
free(msg); free(msg);
return; return;
} }
...@@ -553,10 +556,13 @@ void dvbpsi_message(dvbpsi_t *dvbpsi, const dvbpsi_msg_level_t level, const char ...@@ -553,10 +556,13 @@ void dvbpsi_message(dvbpsi_t *dvbpsi, const dvbpsi_msg_level_t level, const char
va_start(ap, fmt); \ va_start(ap, fmt); \
char *tmp = NULL; \ char *tmp = NULL; \
int err = vasprintf(&tmp, fmt, ap); \ int err = vasprintf(&tmp, fmt, ap); \
if (err < 0) \ if (err < 0) { \
va_end(ap); \
return; \ return; \
} \
char *msg = NULL; \ char *msg = NULL; \
if (asprintf(&msg, DVBPSI_MSG_FORMAT, src, tmp) < 0) { \ if (asprintf(&msg, DVBPSI_MSG_FORMAT, src, tmp) < 0) { \
va_end(ap); \
free(tmp); \ free(tmp); \
return; \ return; \
} \ } \
...@@ -574,10 +580,14 @@ void dvbpsi_message(dvbpsi_t *dvbpsi, const dvbpsi_msg_level_t level, const char ...@@ -574,10 +580,14 @@ void dvbpsi_message(dvbpsi_t *dvbpsi, const dvbpsi_msg_level_t level, const char
va_list ap; \ va_list ap; \
va_start(ap, fmt); \ va_start(ap, fmt); \
char *msg = malloc(DVBPSI_MSG_SIZE); \ char *msg = malloc(DVBPSI_MSG_SIZE); \
if (msg == NULL) \ if (msg == NULL) { \
va_end(ap); \
return; \ return; \
if (snprintf(&msg, DVBPSI_MSG_SIZE, DVBPSI_MSG_FORMAT, src) < 0) \ } \
if (snprintf(&msg, DVBPSI_MSG_SIZE, DVBPSI_MSG_FORMAT, src) < 0) { \
va_end(ap); \
return; \ return; \
} \
int err = vsnprintf(&msg, DVBPSI_MSG_SIZE, fmt, ap); \ int err = vsnprintf(&msg, DVBPSI_MSG_SIZE, fmt, ap); \
va_end(ap); \ va_end(ap); \
if (err > 0) { \ if (err > 0) { \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment