[MPlayer-cvslog] r38367 - in trunk/libvo: jpeg_enc.c jpeg_enc.h vesa_lvo.c vo_3dfx.c vo_dga.c vo_dxr3.c vo_fbdev.c vo_ggi.c vo_md5sum.c vo_sdl.c vo_vesa.c vo_wii.c vo_xv.c vo_xvmc.c vo_xvr100.c vo_zr.c vo_zr2.c

reimar subversion at mplayerhq.hu
Wed Jun 1 21:19:04 EEST 2022


Author: reimar
Date: Wed Jun  1 21:19:04 2022
New Revision: 38367

Log:
libvo: clear freed pointers

Reset them to NULL.
Do the same for files that have been fclose()'d
For files that have been close()'d set to -1.

Fixes trac issue #2387

Modified:
   trunk/libvo/jpeg_enc.c
   trunk/libvo/jpeg_enc.h
   trunk/libvo/vesa_lvo.c
   trunk/libvo/vo_3dfx.c
   trunk/libvo/vo_dga.c
   trunk/libvo/vo_dxr3.c
   trunk/libvo/vo_fbdev.c
   trunk/libvo/vo_ggi.c
   trunk/libvo/vo_md5sum.c
   trunk/libvo/vo_sdl.c
   trunk/libvo/vo_vesa.c
   trunk/libvo/vo_wii.c
   trunk/libvo/vo_xv.c
   trunk/libvo/vo_xvmc.c
   trunk/libvo/vo_xvr100.c
   trunk/libvo/vo_zr.c
   trunk/libvo/vo_zr2.c

Modified: trunk/libvo/jpeg_enc.c
==============================================================================
--- trunk/libvo/jpeg_enc.c	Fri Apr 29 22:00:01 2022	(r38366)
+++ trunk/libvo/jpeg_enc.c	Wed Jun  1 21:19:04 2022	(r38367)
@@ -478,8 +478,9 @@ int jpeg_enc_frame(jpeg_enc_t *j, unsign
 	return put_bits_ptr(&(j->s->pb)) - j->s->pb.buf;
 }
 
-void jpeg_enc_uninit(jpeg_enc_t *j) {
+void jpeg_enc_uninit(jpeg_enc_t **jp) {
+	jpeg_enc_t *j = *jp;
 	ff_mjpeg_encode_close(j->s);
-	av_free(j->s);
-	av_free(j);
+	av_freep(&j->s);
+	av_freep(jp);
 }

Modified: trunk/libvo/jpeg_enc.h
==============================================================================
--- trunk/libvo/jpeg_enc.h	Fri Apr 29 22:00:01 2022	(r38366)
+++ trunk/libvo/jpeg_enc.h	Wed Jun  1 21:19:04 2022	(r38367)
@@ -47,6 +47,6 @@ jpeg_enc_t *jpeg_enc_init(int w, int h,
 int jpeg_enc_frame(jpeg_enc_t *j, unsigned char *y_data,
 		unsigned char *u_data, unsigned char *v_data, char *bufr);
 
-void jpeg_enc_uninit(jpeg_enc_t *j);
+void jpeg_enc_uninit(jpeg_enc_t **j);
 
 #endif /* MPLAYER_JPEG_ENC_H */

Modified: trunk/libvo/vesa_lvo.c
==============================================================================
--- trunk/libvo/vesa_lvo.c	Fri Apr 29 22:00:01 2022	(r38366)
+++ trunk/libvo/vesa_lvo.c	Wed Jun  1 21:19:04 2022	(r38367)
@@ -140,6 +140,7 @@ void vlvo_term( void )
 	ioctl( lvo_handler,MGA_VID_OFF,0 );
 	munmap(frames[0],mga_vid_config.frame_size*mga_vid_config.num_frames);
 	if(lvo_handler != -1) close(lvo_handler);
+	lvo_handler = -1;
 }
 
 static uint32_t vlvo_draw_slice_420(uint8_t *image[], int stride[],

Modified: trunk/libvo/vo_3dfx.c
==============================================================================
--- trunk/libvo/vo_3dfx.c	Fri Apr 29 22:00:01 2022	(r38366)
+++ trunk/libvo/vo_3dfx.c	Wed Jun  1 21:19:04 2022	(r38367)
@@ -474,6 +474,7 @@ uninit(void)
 {
     if( fd != -1 )
         close(fd);
+    fd = -1;
 }
 
 

Modified: trunk/libvo/vo_dga.c
==============================================================================
--- trunk/libvo/vo_dga.c	Fri Apr 29 22:00:01 2022	(r38366)
+++ trunk/libvo/vo_dga.c	Wed Jun  1 21:19:04 2022	(r38367)
@@ -402,6 +402,7 @@ static void uninit(void)
             XF86VidModeSwitchToMode(mDisplay, screen, vo_dga_vidmodes[0]);
             XF86VidModeSwitchToMode(mDisplay, screen, vo_dga_vidmodes[0]);
             XFree(vo_dga_vidmodes);
+            vo_dga_vidmodes = NULL;
         }
 #endif
 #endif

Modified: trunk/libvo/vo_dxr3.c
==============================================================================
--- trunk/libvo/vo_dxr3.c	Fri Apr 29 22:00:01 2022	(r38366)
+++ trunk/libvo/vo_dxr3.c	Wed Jun  1 21:19:04 2022	(r38367)
@@ -150,7 +150,7 @@ typedef struct {
 
 
 static overlay_t *overlay_init(int dev);
-static int overlay_release(overlay_t *);
+static int overlay_release(overlay_t **);
 
 static int overlay_read_state(overlay_t *o, char *path);
 static int overlay_write_state(overlay_t *o, char *path);
@@ -449,13 +449,16 @@ static int config(uint32_t width, uint32
 	spued = malloc(sizeof(encodedata));
 	if (spued == NULL) {
 	        free( osdpicbuf );
+	        osdpicbuf = NULL;
 		mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_DXR3_OutOfMemory);
 		return -1;
 	}
 	spubuf = malloc(sizeof(encodedata));
 	if (spubuf == NULL) {
 	        free( osdpicbuf );
+	        osdpicbuf = NULL;
 		free( spued );
+		spued = NULL;
 		mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_DXR3_OutOfMemory);
 		return -1;
 	}
@@ -678,7 +681,7 @@ static void uninit(void)
 #ifdef CONFIG_X11
 	if (dxr3_overlay) {
 		overlay_set_mode(overlay_data, EM8300_OVERLAY_MODE_OFF);
-		overlay_release(overlay_data);
+		overlay_release(&overlay_data);
 
 		vo_x11_uninit();
 	}
@@ -691,16 +694,21 @@ static void uninit(void)
 
 	if (fd_video != -1) {
 		close(fd_video);
+		fd_video = -1;
 	}
 	if (fd_spu != -1) {
 		close(fd_spu);
+		fd_spu = -1;
 	}
 	if (fd_control != -1) {
 		close(fd_control);
+		fd_control = -1;
 	}
 #ifdef SPU_SUPPORT
 	free(osdpicbuf);
+	osdpicbuf = NULL;
 	free(spued);
+	spued = NULL;
 #endif
 }
 
@@ -845,7 +853,7 @@ static int preinit(const char *arg)
 		overlay_set_keycolor(ov, KEY_COLOR);
 		overlay_set_mode(ov, EM8300_OVERLAY_MODE_OVERLAY);
 		overlay_set_mode(ov, EM8300_OVERLAY_MODE_RECTANGLE);
-		overlay_release(ov);
+		overlay_release(&ov);
 		XCloseDisplay(dpy);
 		/* End of fucked up hack */
 
@@ -913,9 +921,10 @@ static overlay_t *overlay_init(int dev)
     return o;
 }
 
-static int overlay_release(overlay_t *o)
+static int overlay_release(overlay_t **o)
 {
-    free(o);
+    free(*o);
+    *o = NULL;
     return 0;
 }
 #define TYPE_INT 1

Modified: trunk/libvo/vo_fbdev.c
==============================================================================
--- trunk/libvo/vo_fbdev.c	Fri Apr 29 22:00:01 2022	(r38366)
+++ trunk/libvo/vo_fbdev.c	Wed Jun  1 21:19:04 2022	(r38367)
@@ -363,7 +363,9 @@ static int parse_fbmode_cfg(char *cfgfil
 out:
     mp_msg(MSGT_VO, MSGL_V, "%d modes\n", nr_modes);
     free(line);
+    line = NULL;
     fclose(fp);
+    fp = NULL;
     return nr_modes;
 err_out_parse_error:
     mp_msg(MSGT_VO, MSGL_V, "parse error");
@@ -374,7 +376,9 @@ err_out:
     fb_modes = NULL;
     nr_modes = 0;
     free(line);
-    free(fp);
+    line = NULL;
+    fclose(fp);
+    fp = NULL;
     return -2;
 err_out_not_valid:
     mp_msg(MSGT_VO, MSGL_V, "previous mode is not correct");
@@ -1117,7 +1121,9 @@ static void uninit(void)
     }
     vt_set_textarea(0, fb_orig_vinfo.yres);
     close(fb_tty_fd);
+    fb_tty_fd = -1;
     close(fb_dev_fd);
+    fb_dev_fd = -1;
     if (frame_buffer)
         munmap(frame_buffer, fb_size);
     frame_buffer = NULL;

Modified: trunk/libvo/vo_ggi.c
==============================================================================
--- trunk/libvo/vo_ggi.c	Fri Apr 29 22:00:01 2022	(r38366)
+++ trunk/libvo/vo_ggi.c	Wed Jun  1 21:19:04 2022	(r38367)
@@ -454,6 +454,7 @@ static int preinit(const char *arg)
 static void uninit(void)
 {
     free(ggi_conf.driver);
+    ggi_conf.driver = NULL;
 
 #ifdef CONFIG_GGIWMH
     ggiWmhDetach(ggi_conf.vis);

Modified: trunk/libvo/vo_md5sum.c
==============================================================================
--- trunk/libvo/vo_md5sum.c	Fri Apr 29 22:00:01 2022	(r38366)
+++ trunk/libvo/vo_md5sum.c	Wed Jun  1 21:19:04 2022	(r38367)
@@ -266,7 +266,7 @@ static void uninit(void)
 {
     free(md5sum_outfile);
     md5sum_outfile = NULL;
-    if (md5sum_fd && md5sum_fd != stdout) fclose(md5sum_fd);
+    if (md5sum_fd && md5sum_fd != stdout) { fclose(md5sum_fd); md5sum_fd = NULL; }
     av_freep(&md5_context);
 }
 

Modified: trunk/libvo/vo_sdl.c
==============================================================================
--- trunk/libvo/vo_sdl.c	Fri Apr 29 22:00:01 2022	(r38366)
+++ trunk/libvo/vo_sdl.c	Wed Jun  1 21:19:04 2022	(r38367)
@@ -1250,6 +1250,7 @@ static int preinit(const char *arg)
     if(sdl_driver) {
         setenv("SDL_VIDEODRIVER", sdl_driver, 1);
     free(sdl_driver);
+    sdl_driver = NULL;
     }
 
     /* does the user want SDL to try and force Xv */

Modified: trunk/libvo/vo_vesa.c
==============================================================================
--- trunk/libvo/vo_vesa.c	Fri Apr 29 22:00:01 2022	(r38366)
+++ trunk/libvo/vo_vesa.c	Wed Jun  1 21:19:04 2022	(r38367)
@@ -161,7 +161,7 @@ static void vesa_term( void )
   if(init_mode) if((err=vbeSetMode(init_mode,NULL)) != VBE_OK) PRINT_VBE_ERR("vbeSetMode",err);
   init_mode=0;
   if(HAS_DGA()) vbeUnmapVideoBuffer((unsigned long)win.ptr,win.high);
-  if(dga_buffer && !HAS_DGA()) free(dga_buffer);
+  if(dga_buffer && !HAS_DGA()) { free(dga_buffer); dga_buffer = NULL; }
   vbeDestroy();
   if(sws) sws_freeContext(sws);
   sws=NULL;

Modified: trunk/libvo/vo_wii.c
==============================================================================
--- trunk/libvo/vo_wii.c	Fri Apr 29 22:00:01 2022	(r38366)
+++ trunk/libvo/vo_wii.c	Wed Jun  1 21:19:04 2022	(r38367)
@@ -314,7 +314,9 @@ static void uninit(void)
   if (vt_doit)
     vt_set_textarea(0, fb_orig_vinfo.yres);
   close(fb_tty_fd);
+  fb_tty_fd = -1;
   close(fb_dev_fd);
+  fb_dev_fd = -1;
   if (frame_buffer)
     munmap(frame_buffer, fb_size);
   frame_buffer = NULL;

Modified: trunk/libvo/vo_xv.c
==============================================================================
--- trunk/libvo/vo_xv.c	Fri Apr 29 22:00:01 2022	(r38366)
+++ trunk/libvo/vo_xv.c	Wed Jun  1 21:19:04 2022	(r38367)
@@ -311,8 +311,10 @@ static void deallocate_xvimage(int foo)
 #endif
     {
         free(xvimage[foo]->data);
+        xvimage[foo]->data = NULL;
     }
     XFree(xvimage[foo]);
+    xvimage[foo] = NULL;
 
     XSync(mDisplay, False);
     return;

Modified: trunk/libvo/vo_xvmc.c
==============================================================================
--- trunk/libvo/vo_xvmc.c	Fri Apr 29 22:00:01 2022	(r38366)
+++ trunk/libvo/vo_xvmc.c	Wed Jun  1 21:19:04 2022	(r38367)
@@ -223,6 +223,7 @@ shmatfail:
         shmctl(Shminfo.shmid, IPC_RMID, 0);
 shmgetfail:
         XFree(xvimage);
+        xvimage = NULL;
 noshmimage:
         Shmem_Flag = 0;
     }
@@ -256,8 +257,10 @@ static void deallocate_xvimage(void)
 #endif
     {
         free(xvimage->data);
+        xvimage->data = NULL;
     }
     XFree(xvimage);
+    xvimage = NULL;
 
     XSync(mDisplay, False);
     return;

Modified: trunk/libvo/vo_xvr100.c
==============================================================================
--- trunk/libvo/vo_xvr100.c	Fri Apr 29 22:00:01 2022	(r38366)
+++ trunk/libvo/vo_xvr100.c	Wed Jun  1 21:19:04 2022	(r38367)
@@ -286,6 +286,7 @@ static int preinit(const char *arg) {
     if (ioctl(pfb_devfd, FBIOGATTR, &attr) < 0) {
         mp_msg(MSGT_VO, MSGL_ERR, "vo_xvr100: Error: ioctl failed (FBIOGATTR)\n");
         close(pfb_devfd);
+        pfb_devfd = -1;
         return 1;
     }
 
@@ -297,6 +298,7 @@ static int preinit(const char *arg) {
                           MAP_SHARED, pfb_devfd, PFB_VRAM_MMAPBASE)) == MAP_FAILED) {
         mp_msg(MSGT_VO, MSGL_ERR, "vo_xvr100: Error: unable to memory map framebuffer\n");
         close(pfb_devfd);
+        pfb_devfd = -1;
         return 1;
     }
 
@@ -305,6 +307,7 @@ static int preinit(const char *arg) {
         mp_msg(MSGT_VO, MSGL_ERR, "vo_xvr100: Error: unable to memory map framebuffer\n");
         munmap(pfb_vbase, PFB_VRAM_MMAPLEN);
         close(pfb_devfd);
+        pfb_devfd = -1;
         return 1;
     }
 

Modified: trunk/libvo/vo_zr.c
==============================================================================
--- trunk/libvo/vo_zr.c	Fri Apr 29 22:00:01 2022	(r38366)
+++ trunk/libvo/vo_zr.c	Wed Jun  1 21:19:04 2022	(r38367)
@@ -283,6 +283,7 @@ static void uninit_zoran(zr_info_t *zr)
 	if (munmap(zr->buf,zr->zrq.count*zr->zrq.size))
 	   mp_msg(MSGT_VO, MSGL_ERR, "zr: error unmapping buffer\n");
 	close(zr->vdes);
+	zr->des = -1;
 }
 
 static int zr_geometry_sane(geo_t *g, unsigned int width, unsigned int height)
@@ -581,7 +582,7 @@ static void uninit(void) {
 	int j;
 	mp_msg(MSGT_VO, MSGL_V, "zr: uninit called\n");
 	for (j = 0; j < zr_count; j++) {
-		jpeg_enc_uninit(zr_info[j].j);
+		jpeg_enc_uninit(&zr_info[j].j);
 		uninit_zoran(&zr_info[j]);
 	}
 }

Modified: trunk/libvo/vo_zr2.c
==============================================================================
--- trunk/libvo/vo_zr2.c	Fri Apr 29 22:00:01 2022	(r38366)
+++ trunk/libvo/vo_zr2.c	Wed Jun  1 21:19:04 2022	(r38367)
@@ -489,5 +489,7 @@ static void uninit(void) {
 		ERROR("error munmapping buffer: %s\n", strerror(errno));
 
 	if (p->vdes >= 0) close(p->vdes);
+	p->vdes = -1;
 	free(p->subdevice);
+	p->subdevice = NULL;
 }


More information about the MPlayer-cvslog mailing list