<div dir="ltr"><div class="gmail_extra">Patch rewritten and merged in <a href="http://git.m2x.eu/videolan/libdvbpsi.git" target="_blank">http://git.m2x.eu/videolan/libdvbpsi.git</a>, <br>it will show up in <a href="http://git.videolan.org/libdvbpsi.git" target="_blank">git.videolan.org/libdvbpsi.git</a> later on.<br></div><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div><div class="gmail_extra">Kind regards,<br></div>Jean-Paul Saman</div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jun 27, 2014 at 1:15 AM, Timothy Gu <span dir="ltr"><<a href="mailto:timothygu99@gmail.com" target="_blank">timothygu99@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Based on a patch by Guilherme Lima Bernal <<a href="mailto:lb-guilherme@live.com">lb-guilherme@live.com</a>>.<br>
<br>
Signed-off-by: Timothy Gu <<a href="mailto:timothygu99@gmail.com">timothygu99@gmail.com</a>><br>
---<br>
src/dvbpsi.c | 22 +++++++++++++---------<br>
1 file changed, 13 insertions(+), 9 deletions(-)<br>
<br>
diff --git a/src/dvbpsi.c b/src/dvbpsi.c<br>
index 89d4932..141e3df 100644<br>
--- a/src/dvbpsi.c<br>
+++ b/src/dvbpsi.c<br>
@@ -529,14 +529,10 @@ void dvbpsi_message(dvbpsi_t *dvbpsi, const dvbpsi_msg_level_t level, const char<br>
msg = malloc(DVBPSI_MSG_SIZE);<br>
if (msg == NULL) {<br>
va_end(ap);<br>
- return;<br>
- }<br>
- if (snprintf(&msg, DVBPSI_MSG_SIZE, DVBPSI_MSG_FORMAT, ap) < 0) {<br>
- va_end(ap);<br>
free(msg);<br>
return;<br>
}<br>
- int err = vsnprintf(&msg, DVBPSI_MSG_SIZE, fmt, ap);<br>
+ int err = vsnprintf(msg, DVBPSI_MSG_SIZE, fmt, ap);<br>
#endif<br>
va_end(ap);<br>
if (err > DVBPSI_MSG_NONE) {<br>
@@ -575,20 +571,28 @@ void dvbpsi_message(dvbpsi_t *dvbpsi, const dvbpsi_msg_level_t level, const char<br>
free(msg); \<br>
} while(0);<br>
# else<br>
-# define DVBPSI_MSG_COMMON \<br>
+# define DVBPSI_MSG_COMMON(level) \<br>
do { \<br>
va_list ap; \<br>
va_start(ap, fmt); \<br>
char *msg = malloc(DVBPSI_MSG_SIZE); \<br>
- if (msg == NULL) { \<br>
+ char *tmp = malloc(DVBPSI_MSG_SIZE); \<br>
+ if (msg == NULL || tmp == NULL) { \<br>
va_end(ap); \<br>
+ if (msg) \<br>
+ free(msg); \<br>
+ if (tmp) \<br>
+ free(tmp); \<br>
return; \<br>
} \<br>
- if (snprintf(&msg, DVBPSI_MSG_SIZE, DVBPSI_MSG_FORMAT, src) < 0) { \<br>
+ if (vsnprintf(tmp, DVBPSI_MSG_SIZE, fmt, ap) < 0) { \<br>
va_end(ap); \<br>
+ free(tmp); \<br>
+ free(msg); \<br>
return; \<br>
} \<br>
- int err = vsnprintf(&msg, DVBPSI_MSG_SIZE, fmt, ap); \<br>
+ int err = snprintf(msg, DVBPSI_MSG_SIZE, DVBPSI_MSG_FORMAT, src, tmp); \<br>
+ free(tmp); \<br>
va_end(ap); \<br>
if (err > 0) { \<br>
if (dvbpsi->pf_message) \<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.9.1<br>
<br>
_______________________________________________<br>
libdvbpsi-devel mailing list<br>
<a href="mailto:libdvbpsi-devel@videolan.org">libdvbpsi-devel@videolan.org</a><br>
<a href="https://mailman.videolan.org/listinfo/libdvbpsi-devel" target="_blank">https://mailman.videolan.org/listinfo/libdvbpsi-devel</a><br>
</font></span></blockquote></div><br></div>