Commit 7d2e1896 authored by Sam Hocevar's avatar Sam Hocevar

* ./src/misc/messages.c: ouch. when the message queue was full, we were

    using our va_list twice, which caused crashes on architectures where
    va_list is a pointer; we now use va_copy whenever possible.
parent 0d36c01a
......@@ -310,8 +310,27 @@ AC_CACHE_CHECK([for socklen_t], ac_cv_type_socklen_t,
ac_cv_type_socklen_t=yes,
ac_cv_type_socklen_t=no)])
if test x$ac_cv_type_socklen_t != xno; then
AC_DEFINE(HAVE_SOCKLEN_T, 1,
Define if <sys/socket.h> defines socklen_t.)
AC_DEFINE(HAVE_SOCKLEN_T, 1, [Define if <sys/socket.h> defines socklen_t.])
fi
dnl Check for va_copy
AC_CACHE_CHECK([for va_copy], ac_cv_c_va_copy,
AC_TRY_LINK(
[#include <stdarg.h>],
[va_list ap1, ap2; va_copy(ap1,ap2);],
[ac_cv_c_va_copy="yes"],
[ac_cv_c_va_copy="no"]))
if test "$ac_cv_c_va_copy" = "yes"; then
AC_DEFINE(HAVE_VA_COPY, 1, [Define if <stdarg.h> defines va_copy.])
fi
AC_CACHE_CHECK([for __va_copy], ac_cv_c___va_copy,
AC_TRY_LINK(
[#include <stdarg.h>],
[va_list ap1, ap2; __va_copy(ap1,ap2);],
[ac_cv_c___va_copy="yes"],
[ac_cv_c___va_copy="no"]))
if test "$ac_cv_c___va_copy" = "yes"; then
AC_DEFINE(HAVE___VA_COPY, 1, [Define if <stdarg.h> defines __va_copy.])
fi
AC_CHECK_FUNCS(inet_aton,,[
......
......@@ -4,7 +4,7 @@
* modules, especially intf modules. See config.h for output configuration.
*****************************************************************************
* Copyright (C) 1998-2002 VideoLAN
* $Id: messages.c,v 1.32 2003/05/09 00:58:25 titer Exp $
* $Id: messages.c,v 1.33 2003/06/13 03:21:40 sam Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
......@@ -43,11 +43,22 @@
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h> /* close(), write() */
# include <unistd.h> /* close(), write() */
#endif
#include "interface.h"
/*****************************************************************************
* Local macros
*****************************************************************************/
#if defined(HAVE_VA_COPY)
# define vlc_va_copy(dest,src) va_copy(dest,src)
#elif defined(HAVE___VA_COPY)
# define vlc_va_copy(dest,src) __va_copy(dest,src)
#else
# define vlc_va_copy(dest,src) (dest)=(src)
#endif
/*****************************************************************************
* Local prototypes
*****************************************************************************/
......@@ -244,10 +255,11 @@ DECLARE_MSG_FN( __msg_Dbg, VLC_MSG_DBG );
* a warning.
*****************************************************************************/
static void QueueMsg( vlc_object_t *p_this, int i_type, const char *psz_module,
const char *psz_format, va_list args )
const char *psz_format, va_list _args )
{
msg_bank_t * p_bank = &p_this->p_libvlc->msg_bank; /* message bank */
char * psz_str = NULL; /* formatted message string */
va_list args;
msg_item_t * p_item = NULL; /* pointer to message */
msg_item_t item; /* message in case of a full queue */
......@@ -259,7 +271,9 @@ static void QueueMsg( vlc_object_t *p_this, int i_type, const char *psz_module,
* Convert message to string
*/
#if defined(HAVE_VASPRINTF) && !defined(SYS_DARWIN) && !defined( SYS_BEOS )
vlc_va_copy( args, _args );
vasprintf( &psz_str, psz_format, args );
va_end( args );
#else
psz_str = (char*) malloc( i_size * sizeof(char) );
#endif
......@@ -272,13 +286,17 @@ static void QueueMsg( vlc_object_t *p_this, int i_type, const char *psz_module,
#else
fprintf( stderr, "main warning: can't store message: " );
#endif
vlc_va_copy( args, _args );
vfprintf( stderr, psz_format, args );
va_end( args );
fprintf( stderr, "\n" );
return;
}
#if !defined(HAVE_VASPRINTF) || defined(SYS_DARWIN) || defined(SYS_BEOS)
vlc_va_copy( args, _args );
vsnprintf( psz_str, i_size, psz_format, args );
va_end( args );
psz_str[ i_size - 1 ] = 0; /* Just in case */
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment