[vlc-commits] [Git][videolan/vlc][3.0.x] contrib: upnp: Backport a patch to fix building with recent mingw versions
Steve Lhomme (@robUx4)
gitlab at videolan.org
Tue Apr 21 07:21:04 UTC 2026
Steve Lhomme pushed to branch 3.0.x at VideoLAN / VLC
Commits:
b50f5374 by Martin Storsjö at 2026-04-21T06:16:33+00: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.
(cherry picked from commit 4034598d821ea86b4dc2ec9a2577e39a537ac55b)
- - - - -
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
=====================================
@@ -43,6 +43,7 @@ ifdef HAVE_IOS
$(APPLY) $(SRC)/upnp/fix-reuseaddr-option.patch
endif
$(APPLY) $(SRC)/upnp/0001-cmake-add-missing-file-in-Windows-compilation.patch
+ $(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/b50f53745569074b5b8c1f6058cc53ebf81db114
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/b50f53745569074b5b8c1f6058cc53ebf81db114
You're receiving this email because of your account on code.videolan.org.
More information about the vlc-commits
mailing list