From 02fa6224a5170a5912276c9b2150c4b7574745f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Tue, 26 Sep 2006 20:17:43 +0000 Subject: printerr() macros are often used when the pointer "this" is NULL. In those cases the result is an immediate segfault, as it's dereferenced. To avoid this, use fprintf instead of writing in err_str. CVS patchset: 8299 CVS date: 2006/09/26 20:17:43 --- src/input/libdvdnav/dvdnav_internal.h | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/input/libdvdnav/dvdnav_internal.h b/src/input/libdvdnav/dvdnav_internal.h index d6e8bef5b..737ef6387 100644 --- a/src/input/libdvdnav/dvdnav_internal.h +++ b/src/input/libdvdnav/dvdnav_internal.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: dvdnav_internal.h,v 1.16 2006/09/17 13:01:08 valtri Exp $ + * $Id: dvdnav_internal.h,v 1.17 2006/09/26 20:17:43 dgp85 Exp $ * */ @@ -202,6 +202,10 @@ struct dvdnav_s { /** USEFUL MACROS **/ +/* printerr*() are often called when this is NULL. Avoid segfaults by replacing these with + * more common prints + */ +#if 0 #ifdef __GNUC__ #define printerrf(format, args...) snprintf(this->err_str, MAX_ERR_LEN, format, ## args); #else @@ -212,5 +216,17 @@ struct dvdnav_s { #endif /* WIN32 */ #endif #define printerr(str) strncpy(this->err_str, str, MAX_ERR_LEN); +#endif + +#ifdef __GNUC__ +#define printerrf(format, args...) fprintf(stderr, format, ## args); +#else +#ifdef _MSC_VER +#define printerrf(str) fprintf(stderr, str); +#else +#define printerrf(...) fprintf(stderr, __VA_ARGS__); +#endif /* WIN32 */ +#endif +#define printerr(str) fprintf(stderr, "%s", str); #endif /* DVDNAV_INTERNAL_H_INCLUDED */ -- cgit v1.2.3