From 46e9880c625972c3a9ac7c0b53bc1a30c2989b7c Mon Sep 17 00:00:00 2001 From: Daniel Jacobowitz Date: Thu, 2 Feb 2006 02:26:48 +0000 Subject: * printcmd.c (printf_command): Make format string checking stricter. Add separate cases for long_arg, ptr_arg, and long_double_arg. * utils.c (xstrvprintf): Improve the error message issued for a bad format string. * Makefile.in (GDB_WARN_CFLAGS_NO_FORMAT, INTERNAL_CFLAGS_BASE): New variables. (gnu-v3-abi.o, monitor.o, procfs.o, linux-thread-db.o): Remove $(NO_WERROR_CFLAGS). (printcmd.o): Likewise. Use $(GDB_WARN_CFLAGS_NO_FORMAT) and enable -Werror. --- gdb/utils.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'gdb/utils.c') diff --git a/gdb/utils.c b/gdb/utils.c index fdebbdc..dff5cb8 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -1,8 +1,8 @@ /* General utility routines for GDB, the GNU debugger. Copyright (C) 1986, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, - 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free - Software Foundation, Inc. + 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. This file is part of GDB. @@ -1069,14 +1069,12 @@ xstrvprintf (const char *format, va_list ap) { char *ret = NULL; int status = vasprintf (&ret, format, ap); - /* NULL is returned when there was a memory allocation problem. */ - if (ret == NULL) - nomem (0); - /* A negative status (the printed length) with a non-NULL buffer - should never happen, but just to be sure. */ - if (status < 0) - internal_error (__FILE__, __LINE__, - _("vasprintf call failed (errno %d)"), errno); + /* NULL is returned when there was a memory allocation problem, or + any other error (for instance, a bad format string). A negative + status (the printed length) with a non-NULL buffer should never + happen, but just to be sure. */ + if (ret == NULL || status < 0) + internal_error (__FILE__, __LINE__, _("vasprintf call failed")); return ret; } -- cgit v1.1