Em Sun, 26 Oct 2014 20:46:17 +0900
tsk...@gmail.com escreveu:

> From: Akihiro Tsukada <tsk...@gmail.com>
> 
> when channel name was not available, it was generated from unset variables,
> and leaked memory.
> ---
>  lib/libdvbv5/dvb-file.c | 28 +++++++++++++++++++---------
>  1 file changed, 19 insertions(+), 9 deletions(-)


I suspect that you're using an older version of the git respository.
The patch didn't apply. After forcing it, the patch became the enclosed
change.

I suspect, however, that this will actually cause a core dump, as
get_program_and_store() is called with a NULL parameter for channel,
when !SDT.

Are you sure that such memory leak still happens with the current
version? I remember I tested it with valgrind and was unable to find
any case where a memory leak was happening.

For now, I'll be just applying this change on a separate patch:

-               r = asprintf(&channel, "%.2fMHz#%d", freq/1000000., service_id);
+               r = asprintf(&channel, "%.2f%cHz#%d", freq / 1000000.,
+                       dvb_fe_is_satellite(parms->p.current_sys) ? 'G' : 'M',
+                       service_id);

If you're still noticing this bug, please send a fix against the latest
upstream version.

Regards,
Mauro

diff --git a/lib/libdvbv5/dvb-file.c b/lib/libdvbv5/dvb-file.c
index 479f47eda862..bbed60832e92 100644
--- a/lib/libdvbv5/dvb-file.c
+++ b/lib/libdvbv5/dvb-file.c
@@ -1141,8 +1141,11 @@ static int get_program_and_store(struct 
dvb_v5_fe_parms_priv *parms,
                if (!channel && entry->props[j].cmd == DTV_FREQUENCY)
                        freq = parms->dvb_prop[j].u.data;
        }
-       if (!channel) {
-               r = asprintf(&channel, "%.2fMHz#%d", freq/1000000., service_id);
+       if (!*channel) {
+               free(channel);
+               r = asprintf(&channel, "%.2f%cHz#%d", freq / 1000000.,
+                       dvb_fe_is_satellite(parms->p.current_sys) ? 'G' : 'M',
+                       service_id);
                if (r < 0)
                        dvb_perror("asprintf");
                dvb_log("Storing Service ID %d: '%s'", service_id, channel);
@@ -1240,13 +1243,20 @@ int dvb_store_channel(struct dvb_file **dvb_file,
                        if (!warned) {
                                dvb_log("WARNING: no SDT table - storing 
channel(s) without their names");
                                warned = 1;
+
+                       rc = asprintf(&channel, "#%d", service_id);
+                       if (rc < 0) {
+                               dvb_perror("asprintf");
+                               return rc;
                        }
 
                        rc = get_program_and_store(parms, *dvb_file, 
dvb_scan_handler,
                                                   service_id, NULL, NULL,
                                                   get_detected, get_nit);
-                       if (rc < 0)
+                       if (rc < 0) {
+                               free(channel);
                                return rc;
+                       }
                }
 
                return 0;
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to