mtp: fix initialization to avoid segfault on close
authorRomain Vimont <rom@rom1v.com>
Fri, 10 Nov 2017 21:56:42 +0000 (22:56 +0100)
committerJean-Baptiste Kempf <jb@videolan.org>
Sat, 11 Nov 2017 14:03:00 +0000 (15:03 +0100)
When an Android device is plugged with MTP disabled, the tracks may not
be retrieved.

In that branch of code, pp_items was never initialized, so the behavior
was undefined in CloseDevice() (on device unplug), often causing a
segfault.

Initialize it to NULL to fix the problem.

Signed-off-by: Romain Vimont <rom@rom1v.com>
Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
modules/services_discovery/mtp.c

index 56be3e3..b64f84e 100644 (file)
@@ -198,6 +198,7 @@ static int AddDevice( services_discovery_t *p_sd,
                             CountTracks, p_sd ) ) == NULL )
         {
             msg_Warn( p_sd, "No tracks on the device" );
+            p_sd->p_sys->pp_items = NULL;
         }
         else
         {