From 639bd610bfcb1a028b91a5c3d125045c8de6d8b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Dvo=C5=99=C3=A1k?= Date: Wed, 5 Apr 2006 22:12:17 +0000 Subject: 1) various warning fixes 2) [coverity] fixes: - 279 (w32): test should be on input parametr type, not typeW - 267 (aout): can be ignored but there was warning anyway - 234 (w32): missing free on error & exit - 152 (w32): missing free on error & exit - 148 (w32): fixed bound of static array in test - 101 (ffdec): defense code when avodec_encode_video will fail (just defense to the future, should never happen with current ffmpeg in xine) - 98, 99 (w32): check negative handle by _x_assert (it's used as index to array) - 90 (w32): negate pointer check (+added check for size) - 89 (w32): added NULL and size check CVS patchset: 7959 CVS date: 2006/04/05 22:12:17 --- ChangeLog | 1 + src/demuxers/demux_slave.c | 4 ++-- src/demuxers/id3.c | 4 +++- src/input/input_mms.c | 6 +----- src/input/input_pnm.c | 4 ---- src/input/input_rtsp.c | 4 ---- src/input/input_vcd.c | 4 ++-- src/input/media_helper.c | 3 ++- src/libffmpeg/xine_encoder.c | 8 +++++++- src/libw32dll/DirectShow/outputpin.c | 1 + src/libw32dll/wine/driver.c | 4 ++-- src/libw32dll/wine/ldt_keeper.c | 3 ++- src/libw32dll/wine/pe_resource.c | 2 +- src/libw32dll/wine/win32.c | 11 +++++++---- src/video_out/video_out_vidix.c | 4 +++- src/xine-engine/audio_out.c | 4 +++- src/xine-engine/demux.c | 6 +++--- src/xine-engine/video_overlay.c | 6 +++--- src/xine-utils/list.c | 4 ++-- src/xine-utils/list.h | 4 ++-- src/xine-utils/ring_buffer.c | 6 +++--- 21 files changed, 50 insertions(+), 43 deletions(-) diff --git a/ChangeLog b/ChangeLog index 138d4d430..87d3320c2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -18,6 +18,7 @@ xine-lib (1.1.2) * New volume normalization post plugin * New image noise post plugin (useful for mitigating some compression artifacts) * Support for Vorbis-style comments in FLAC files + * Coverity fixes xine-lib (1.1.1) * Improve sound quality when using alsa 1.0.9 or above. diff --git a/src/demuxers/demux_slave.c b/src/demuxers/demux_slave.c index ffad53107..8aa7399e4 100644 --- a/src/demuxers/demux_slave.c +++ b/src/demuxers/demux_slave.c @@ -21,7 +21,7 @@ */ /* - * $Id: demux_slave.c,v 1.17 2006/03/11 08:55:10 tmattern Exp $ + * $Id: demux_slave.c,v 1.18 2006/04/05 22:12:18 valtri Exp $ * * demuxer for slave "protocol" * master xine must be started with XINE_PARAM_BROADCASTER_PORT set, that is, @@ -303,7 +303,7 @@ static void demux_slave_dispose (demux_plugin_t *this_gen) { xine_list_iterator_t ite; /* free all decoder information */ - while (ite = xine_list_front(this->dec_infos)) { + while ((ite = xine_list_front(this->dec_infos)) != NULL) { data = xine_list_get_value(this->dec_infos, ite); free(data); xine_list_remove (this->dec_infos, ite); diff --git a/src/demuxers/id3.c b/src/demuxers/id3.c index 29cb3d4c4..ffa022a59 100644 --- a/src/demuxers/id3.c +++ b/src/demuxers/id3.c @@ -29,7 +29,7 @@ * * ID3v2 specs: http://www.id3.org/ * - * $Id: id3.c,v 1.11 2005/09/16 23:01:10 tmattern Exp $ + * $Id: id3.c,v 1.12 2006/04/05 22:12:18 valtri Exp $ */ #ifdef HAVE_CONFIG_H @@ -227,11 +227,13 @@ static int id3v2_parse_genre(char* dest, char *src, int len) { return 1; } +#if 0 /* parse an unsynchronized 16bits integer */ static uint16_t BE_16_synchsafe(uint8_t buf[2]) { return ((uint16_t)(buf[0] & 0x7F) << 7) | (uint16_t)(buf[1] & 0x7F); } +#endif /* parse an unsynchronized 24bits integer */ static uint32_t BE_24_synchsafe(uint8_t buf[3]) { diff --git a/src/input/input_mms.c b/src/input/input_mms.c index 7ba14765b..4cc7e73e7 100644 --- a/src/input/input_mms.c +++ b/src/input/input_mms.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: input_mms.c,v 1.59 2006/03/25 11:59:29 hadess Exp $ + * $Id: input_mms.c,v 1.60 2006/04/05 22:12:19 valtri Exp $ * * mms input plugin based on work from major mms */ @@ -55,10 +55,6 @@ #define PROTOCOL_MMST 1 #define PROTOCOL_MMSH 2 -#if !defined(NDELAY) && defined(O_NDELAY) -#define FNDELAY O_NDELAY -#endif - /* network bandwidth */ const uint32_t mms_bandwidths[]={14400,19200,28800,33600,34430,57600, 115200,262200,393216,524300,1544000,10485800}; diff --git a/src/input/input_pnm.c b/src/input/input_pnm.c index 6e93cffad..7d1cddbd7 100644 --- a/src/input/input_pnm.c +++ b/src/input/input_pnm.c @@ -50,10 +50,6 @@ #define BUFSIZE 4096 -#if !defined(NDELAY) && defined(O_NDELAY) -#define FNDELAY O_NDELAY -#endif - typedef struct { input_class_t input_class; diff --git a/src/input/input_rtsp.c b/src/input/input_rtsp.c index 47e8a9654..947d9b146 100644 --- a/src/input/input_rtsp.c +++ b/src/input/input_rtsp.c @@ -50,10 +50,6 @@ #define BUFSIZE 1025 -#if !defined(NDELAY) && defined(O_NDELAY) -#define FNDELAY O_NDELAY -#endif - typedef struct { input_class_t input_class; diff --git a/src/input/input_vcd.c b/src/input/input_vcd.c index 42c183fb7..ab4f004b1 100644 --- a/src/input/input_vcd.c +++ b/src/input/input_vcd.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: input_vcd.c,v 1.82 2006/03/29 21:00:45 valtri Exp $ + * $Id: input_vcd.c,v 1.83 2006/04/05 22:12:19 valtri Exp $ * */ @@ -623,6 +623,7 @@ static buf_element_t *vcd_plugin_read_block (input_plugin_t *this_gen, } #endif +#if defined (__linux__) || defined(__sun) || defined(HOST_OS_DARWIN) static off_t vcd_time_to_offset (int min, int sec, int frame) { return min * 60 * 75 + sec * 75 + frame; } @@ -637,7 +638,6 @@ static void vcd_offset_to_time (off_t offset, uint8_t *min, uint8_t *sec, } -#if defined (__linux__) || defined(__sun) || defined(HOST_OS_DARWIN) static off_t vcd_plugin_seek (input_plugin_t *this_gen, off_t offset, int origin) { diff --git a/src/input/media_helper.c b/src/input/media_helper.c index 2c61cdb6a..da30783b0 100644 --- a/src/input/media_helper.c +++ b/src/input/media_helper.c @@ -93,7 +93,7 @@ int media_eject_media (xine_t *xine, const char *device) #else - int ret, status, fd; + int fd; /* printf("input_dvd: Eject Device %s current device %s opened=%d handle=%p trying...\n",device, this->current_dvd_device, this->opened, this->dvdnav); */ media_umount_media(device); @@ -102,6 +102,7 @@ int media_eject_media (xine_t *xine, const char *device) if ((fd = open (device, O_RDONLY|O_NONBLOCK)) > -1) { #if defined (__linux__) + int ret, status; if((status = ioctl(fd, CDROM_DRIVE_STATUS, CDSL_CURRENT)) > 0) { switch(status) { diff --git a/src/libffmpeg/xine_encoder.c b/src/libffmpeg/xine_encoder.c index e2fb95389..f2442f00d 100644 --- a/src/libffmpeg/xine_encoder.c +++ b/src/libffmpeg/xine_encoder.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: xine_encoder.c,v 1.21 2005/05/06 04:22:51 tmmm Exp $ + * $Id: xine_encoder.c,v 1.22 2006/04/05 22:12:19 valtri Exp $ */ /* mpeg encoders for the dxr3 video out plugin. */ @@ -247,6 +247,12 @@ static int lavc_on_display_frame(dxr3_driver_t *drv, dxr3_frame_t *frame) frame->vo_frame.free(&frame->vo_frame); + if (size < 0) { + xprintf(drv->class->xine, XINE_VERBOSITY_LOG, + "dxr3_mpeg_encoder: encoding failed\n"); + return 0; + } + written = write(drv->fd_video, this->ffmpeg_buffer, size); if (written < 0) { xprintf(drv->class->xine, XINE_VERBOSITY_LOG, diff --git a/src/libw32dll/DirectShow/outputpin.c b/src/libw32dll/DirectShow/outputpin.c index f971951f3..acff3ac16 100644 --- a/src/libw32dll/DirectShow/outputpin.c +++ b/src/libw32dll/DirectShow/outputpin.c @@ -487,6 +487,7 @@ COutputPin* COutputPinCreate(const AM_MEDIA_TYPE* amt) if (!This->vt || !This->mempin || !ivt) { COutputPin_Destroy(This); + free(ivt); return NULL; } diff --git a/src/libw32dll/wine/driver.c b/src/libw32dll/wine/driver.c index 923622aaa..ef8761628 100644 --- a/src/libw32dll/wine/driver.c +++ b/src/libw32dll/wine/driver.c @@ -168,7 +168,7 @@ HDRVR DrvOpen(LPARAM lParam2) return ((HDRVR) 0); } - TRACE("DriverProc == %X\n", hDriver->DriverProc); + TRACE("DriverProc == %p\n", hDriver->DriverProc); SendDriverMessage((HDRVR)hDriver, DRV_LOAD, 0, 0); TRACE("DRV_LOAD Ok!\n"); SendDriverMessage((HDRVR)hDriver, DRV_ENABLE, 0, 0); @@ -177,7 +177,7 @@ HDRVR DrvOpen(LPARAM lParam2) // open driver and remmeber proper DriverID hDriver->dwDriverID = SendDriverMessage((HDRVR)hDriver, DRV_OPEN, (LPARAM) unknown, lParam2); - TRACE("DRV_OPEN Ok!(%X)\n", hDriver->dwDriverID); + TRACE("DRV_OPEN Ok!(%lX)\n", hDriver->dwDriverID); printf("Loaded DLL driver %s\n", filename); return (HDRVR)hDriver; diff --git a/src/libw32dll/wine/ldt_keeper.c b/src/libw32dll/wine/ldt_keeper.c index 6941dca39..49cdc4e87 100644 --- a/src/libw32dll/wine/ldt_keeper.c +++ b/src/libw32dll/wine/ldt_keeper.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: ldt_keeper.c,v 1.13 2004/09/21 19:35:57 hadess Exp $ + * $Id: ldt_keeper.c,v 1.14 2006/04/05 22:12:21 valtri Exp $ * * * contents: @@ -293,6 +293,7 @@ ldt_fs_t* Setup_LDT_Keeper(void) ldt_fs->fd = open("/dev/zero", O_RDWR); if(ldt_fs->fd<0){ perror( "Cannot open /dev/zero for READ+WRITE. Check permissions! error: "); + free(ldt_fs); return NULL; } diff --git a/src/libw32dll/wine/pe_resource.c b/src/libw32dll/wine/pe_resource.c index 5d7f3d234..2af09f60e 100644 --- a/src/libw32dll/wine/pe_resource.c +++ b/src/libw32dll/wine/pe_resource.c @@ -343,7 +343,7 @@ PE_EnumResourceLanguagesA( else typeW = (LPWSTR)type; resdir = GetResDirEntryW(resdir,typeW,(DWORD)pem->pe_resource,FALSE); - if (HIWORD(typeW)) + if (HIWORD(type)) HeapFree(heap,0,typeW); if (!resdir) return FALSE; diff --git a/src/libw32dll/wine/win32.c b/src/libw32dll/wine/win32.c index 940750b7e..8a3d004a5 100644 --- a/src/libw32dll/wine/win32.c +++ b/src/libw32dll/wine/win32.c @@ -1430,7 +1430,7 @@ static void WINAPI expDeleteCriticalSection(CRITICAL_SECTION *c) static int WINAPI expGetCurrentThreadId() { dbgprintf("GetCurrentThreadId() => %d\n", pthread_self()); - return pthread_self(); + return (int)pthread_self(); } static int WINAPI expGetCurrentProcess() { @@ -1519,7 +1519,7 @@ static int WINAPI expTlsFree(int idx) { int index = (int) idx; dbgprintf("TlsFree(%d)\n",index); - if((index<0) || (index>64)) + if((index<0) || (index>=64)) return 0; tls_use_map[index]=0; return 1; @@ -2619,7 +2619,7 @@ static int WINAPI expEnumWindows(int (*callback_func)(), void *callback_param) static int WINAPI expGetWindowThreadProcessId(HWND win, int *pid_data) { - int tid = pthread_self(); + int tid = (int)pthread_self(); dbgprintf("GetWindowThreadProcessId(0x%x, 0x%x) => %d\n", win, pid_data, tid); if (pid_data) @@ -3131,6 +3131,8 @@ static int WINAPI expGetEnvironmentVariableA(const char* name, char* field, int p = getenv(name); if (p) strncpy(field,p,size); */ + if (!field || size < sizeof("__GLOBAL_HEAP_SELECTED,1")) + return 0; if (strcmp(name,"__MSVCRT_HEAP_SELECT")==0) strcpy(field,"__GLOBAL_HEAP_SELECTED,1"); dbgprintf("GetEnvironmentVariableA(0x%x='%s', 0x%x, %d) => %d\n", name, name, field, size, strlen(field)); @@ -3558,7 +3560,8 @@ static UINT WINAPI expGetSystemDirectoryA( UINT uSize // size of directory buffer ){ dbgprintf("GetSystemDirectoryA(%p,%d)\n", lpBuffer,uSize); - if(!lpBuffer) strcpy(lpBuffer,"."); + if (!lpBuffer || uSize < 2) return 0; + strcpy(lpBuffer,"."); return 1; } /* diff --git a/src/video_out/video_out_vidix.c b/src/video_out/video_out_vidix.c index a6aaea0e1..9bef113be 100644 --- a/src/video_out/video_out_vidix.c +++ b/src/video_out/video_out_vidix.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: video_out_vidix.c,v 1.70 2005/09/25 00:44:04 miguelfreitas Exp $ + * $Id: video_out_vidix.c,v 1.71 2006/04/05 22:12:19 valtri Exp $ * * video_out_vidix.c * @@ -343,6 +343,7 @@ static uint32_t vidix_get_capabilities (vo_driver_t *this_gen) { return this->capabilities; } +#ifdef HAVE_FB static void vidixfb_frame_output_cb(void *user_data, int video_width, int video_height, double video_pixel_aspect, int *dest_x, int *dest_y, int *dest_width, int *dest_height, double *dest_pixel_aspect, int *win_x, int *win_y) { vidix_driver_t *this = (vidix_driver_t *) user_data; @@ -354,6 +355,7 @@ static void vidixfb_frame_output_cb(void *user_data, int video_width, int video_ *win_x = 0; *win_y = 0; } +#endif static void vidix_frame_field (vo_frame_t *vo_img, int which_field) { /* not needed for vidix */ diff --git a/src/xine-engine/audio_out.c b/src/xine-engine/audio_out.c index 57f55ab56..cceccc980 100644 --- a/src/xine-engine/audio_out.c +++ b/src/xine-engine/audio_out.c @@ -17,7 +17,7 @@ * along with self program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: audio_out.c,v 1.200 2006/03/24 20:05:38 dsalt Exp $ + * $Id: audio_out.c,v 1.201 2006/04/05 22:12:20 valtri Exp $ * * 22-8-2001 James imported some useful AC3 sections from the previous alsa driver. * (c) 2001 Andy Lo A Foe @@ -977,6 +977,7 @@ static void *ao_loop (void *this_gen) { last_sync_time = bufs_since_sync = 0; in_buf = NULL; + cur_time = -1; while ((this->audio_loop_running) || (!this->audio_loop_running && this->out_fifo->first)) { @@ -1034,6 +1035,7 @@ static void *ao_loop (void *this_gen) { } } + _x_assert(cur_time >= 0); if ((in_buf->vpts - cur_time) > 2 * 90000) xprintf (this->xine, XINE_VERBOSITY_DEBUG, "audio_out: vpts/clock error, in_buf->vpts=%" PRId64 " cur_time=%" PRId64 "\n", diff --git a/src/xine-engine/demux.c b/src/xine-engine/demux.c index 9a7345d42..40ee9f7d3 100644 --- a/src/xine-engine/demux.c +++ b/src/xine-engine/demux.c @@ -20,7 +20,7 @@ * Demuxer helper functions * hide some xine engine details from demuxers and reduce code duplication * - * $Id: demux.c,v 1.61 2006/01/24 22:25:34 molivier Exp $ + * $Id: demux.c,v 1.62 2006/04/05 22:12:20 valtri Exp $ */ @@ -634,8 +634,8 @@ void _x_demux_send_mrl_reference (xine_stream_t *stream, int alternative, data.e->alternative = alternative; data.e->start_time = start_time; data.e->duration = duration; - strcpy (data.e->mrl, mrl); - strcpy (data.e->mrl + mrl_len + 1, title ? title : ""); + strcpy((char *)data.e->mrl, mrl); + strcpy((char *)data.e->mrl + mrl_len + 1, title ? title : ""); event.type = XINE_EVENT_MRL_REFERENCE_EXT; xine_event_send (stream, &event); diff --git a/src/xine-engine/video_overlay.c b/src/xine-engine/video_overlay.c index c312aea1a..388649a7e 100644 --- a/src/xine-engine/video_overlay.c +++ b/src/xine-engine/video_overlay.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2000-2003 the xine project + * Copyright (C) 2000-2006 the xine project * * This file is part of xine, a free video player. * @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: video_overlay.c,v 1.39 2005/09/25 00:44:04 miguelfreitas Exp $ + * $Id: video_overlay.c,v 1.40 2006/04/05 22:12:20 valtri Exp $ * */ @@ -347,8 +347,8 @@ static int video_overlay_event( video_overlay_t *this, int64_t vpts ) { handle=this->events[this_event].event->object.handle; #ifdef LOG_DEBUG printf ("video_overlay: video_overlay_event: handle = %d\n", handle); - assert(handle >=0); #endif + _x_assert(handle >= 0); switch( this->events[this_event].event->event_type ) { case OVERLAY_EVENT_SHOW: #ifdef LOG_DEBUG diff --git a/src/xine-utils/list.c b/src/xine-utils/list.c index 88de77fda..6d5d876bf 100644 --- a/src/xine-utils/list.c +++ b/src/xine-utils/list.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: list.c,v 1.10 2006/01/27 07:46:16 tmattern Exp $ + * $Id: list.c,v 1.11 2006/04/05 22:12:20 valtri Exp $ * */ @@ -138,7 +138,7 @@ static void xine_list_recycle_elem(xine_list_t *list, xine_list_elem_t *elem) { } /* List constructor */ -xine_list_t *xine_list_new() { +xine_list_t *xine_list_new(void) { xine_list_t *new_list; new_list = (xine_list_t*)malloc(sizeof(xine_list_t)); diff --git a/src/xine-utils/list.h b/src/xine-utils/list.h index 57f131642..5b5f3532e 100644 --- a/src/xine-utils/list.h +++ b/src/xine-utils/list.h @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: list.h,v 1.2 2006/01/27 07:46:16 tmattern Exp $ + * $Id: list.h,v 1.3 2006/04/05 22:12:20 valtri Exp $ * * Doubly-linked linked list. * @@ -50,7 +50,7 @@ typedef struct xine_list_s xine_list_t; typedef void* xine_list_iterator_t; /* Constructor */ -xine_list_t *xine_list_new(); +xine_list_t *xine_list_new(void); /* Destructor */ void xine_list_delete(xine_list_t *list); diff --git a/src/xine-utils/ring_buffer.c b/src/xine-utils/ring_buffer.c index 9fe14f30f..a98e1f261 100644 --- a/src/xine-utils/ring_buffer.c +++ b/src/xine-utils/ring_buffer.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: ring_buffer.c,v 1.2 2006/01/27 19:37:15 tmattern Exp $ + * $Id: ring_buffer.c,v 1.3 2006/04/05 22:12:20 valtri Exp $ * */ #ifdef HAVE_CONFIG_H @@ -44,14 +44,14 @@ struct xine_ring_buffer_chunk_s { }; /* init */ -void xine_ring_buffer_chunk_create(void *object) { +static void xine_ring_buffer_chunk_create(void *object) { xine_ring_buffer_chunk_t *chunk = (xine_ring_buffer_chunk_t *)object; chunk->mem = NULL; chunk->size = 0; } /* cleanup */ -void xine_ring_buffer_chunk_return(void *object) { +static void xine_ring_buffer_chunk_return(void *object) { xine_ring_buffer_chunk_t *chunk = (xine_ring_buffer_chunk_t *)object; chunk->mem = NULL; chunk->size = 0; -- cgit v1.2.3