From b0afb8fe0ff1d87165af9df61501197a06240dda Mon Sep 17 00:00:00 2001 From: Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> Date: Sun, 28 Dec 2025 12:13:40 +0100 Subject: Sync with Gnulib stable-202507 code (a8ac9f9ce5) --- gl/vasprintf.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'gl/vasprintf.c') diff --git a/gl/vasprintf.c b/gl/vasprintf.c index e52aaca5..30aa4469 100644 --- a/gl/vasprintf.c +++ b/gl/vasprintf.c @@ -1,5 +1,5 @@ /* Formatted output to strings. - Copyright (C) 1999, 2002, 2006-2024 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006-2025 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -25,6 +25,7 @@ #include #include +#include #include #include "vasnprintf.h" @@ -37,12 +38,21 @@ vasprintf (char **resultp, const char *format, va_list args) if (result == NULL) return -1; +#if PTRDIFF_MAX > INT_MAX if (length > INT_MAX) { free (result); - errno = EOVERFLOW; + errno = (length > PTRDIFF_MAX ? ENOMEM : EOVERFLOW); return -1; } +#else + if (length > PTRDIFF_MAX) + { + free (result); + errno = ENOMEM; + return -1; + } +#endif *resultp = result; /* Return the number of resulting bytes, excluding the trailing NUL. */ -- cgit v1.2.3-74-g34f1