[vlc-commits] [Git][videolan/vlc][master] contrib: upnp: Backport a patch to fix building with recent mingw versions

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Tue Apr 14 22:39:47 UTC 2026



Felix Paul Kühne pushed to branch master at VideoLAN / VLC


Commits:
4034598d by Martin Storsjö at 2026-04-14T23:35:10+02:00
contrib: upnp: Backport a patch to fix building with recent mingw versions

Recent versions of mingw-w64 do provide the strndup function.
Upnp used to hardcode that it has to provide its own strndup on
Windows, even though it also had done a configure check for the
function.

This backports commit 679d5b7775386a8dc4d0fffe792dac3a00e5fe41 from
the upstream project.

- - - - -


2 changed files:

- + contrib/src/upnp/0001-Don-t-assume-strndup-to-be-missing-on-Windows.patch
- contrib/src/upnp/rules.mak


Changes:

=====================================
contrib/src/upnp/0001-Don-t-assume-strndup-to-be-missing-on-Windows.patch
=====================================
@@ -0,0 +1,42 @@
+From 679d5b7775386a8dc4d0fffe792dac3a00e5fe41 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <martin at martin.st>
+Date: Mon, 13 Apr 2026 20:47:25 +0300
+Subject: [PATCH] Don't assume strndup to be missing on Windows
+
+Recent (git) versions of mingw-w64 have started providing the
+strndup function (because it is part of C23).
+
+The configure check for HAVE_STRNDUP does detect this correctly,
+thus just rely on that check instead of hardcoding extra
+conditions on top of it.
+
+This fixes building with such versions of mingw-w64.
+---
+ upnp/src/api/UpnpString.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/upnp/src/api/UpnpString.c b/upnp/src/api/UpnpString.c
+index a554a423..9e0dfd5a 100644
+--- a/upnp/src/api/UpnpString.c
++++ b/upnp/src/api/UpnpString.c
+@@ -42,7 +42,7 @@ static size_t strnlen(const char *s, size_t n)
+ #endif		       /* _WIN32 */
+ 
+ /* strndup() is a GNU extension. */
+-#if !HAVE_STRNDUP || defined(_WIN32)
++#if !HAVE_STRNDUP
+ static char *strndup(const char *__string, size_t __n)
+ {
+ 	size_t strsize = strnlen(__string, __n);
+@@ -55,7 +55,7 @@ static char *strndup(const char *__string, size_t __n)
+ 
+ 	return newstr;
+ }
+-#endif /* HAVE_STRNDUP && !defined(_WIN32) */
++#endif /* !HAVE_STRNDUP */
+ 
+ /*!
+  * \brief Internal implementation of the class UpnpString.
+-- 
+2.43.0
+


=====================================
contrib/src/upnp/rules.mak
=====================================
@@ -42,6 +42,7 @@ endif
 ifdef HAVE_IOS
 	$(APPLY) $(SRC)/upnp/fix-reuseaddr-option.patch
 endif
+	$(APPLY) $(SRC)/upnp/0001-Don-t-assume-strndup-to-be-missing-on-Windows.patch
 	$(MOVE)
 
 .upnp: upnp toolchain.cmake



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/4034598d821ea86b4dc2ec9a2577e39a537ac55b

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/4034598d821ea86b4dc2ec9a2577e39a537ac55b
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list