diff --git a/meta/recipes-devtools/flex/flex/0001-lib-malloc-declare-malloc-via-stdlib.h.patch b/meta/recipes-devtools/flex/flex/0001-lib-malloc-declare-malloc-via-stdlib.h.patch
new file mode 100644
index 0000000000..a64d6220a8
--- /dev/null
+++ b/meta/recipes-devtools/flex/flex/0001-lib-malloc-declare-malloc-via-stdlib.h.patch
@@ -0,0 +1,38 @@
+From: Aurelien Desbrieres <aurelien@hackers.camp>
+Date: Sat, 13 Sep 2026 00:00:00 +0200
+Subject: [PATCH] lib/malloc.c: declare malloc via stdlib.h
+
+The gnulib fallback declares "void *malloc ();" with an empty parameter
+list and calls it with one argument. That meant "unspecified" in C89 and
+means "none" in C23, which GCC 14 and later implement by default, so the
+call is rejected:
+
+  lib/malloc.c:16:15: error: too many arguments to function 'malloc';
+                             expected 0, have 1
+
+stdlib.h has the right declaration and the file already includes
+sys/types.h for size_t, so the local one has nothing to add.
+lib/realloc.c includes stdlib.h already and needs no change.
+
+The file is dead code wherever malloc(0) returns non-NULL -- glibc
+included -- since AC_FUNC_MALLOC substitutes rpl_malloc only where it
+does not, but it is compiled regardless and the build stops there.
+
+Upstream-Status: Inappropriate [flex 2.6.4 is the last release, 2017]
+
+Signed-off-by: Aurelien Desbrieres <aurelien@hackers.camp>
+---
+ lib/malloc.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/lib/malloc.c
++++ b/lib/malloc.c
+@@ -3,7 +3,7 @@
+      
+      #include <sys/types.h>
+      
+-     void *malloc ();
++#include <stdlib.h>
+      
+      /* Allocate an N-byte block of memory from the heap.
+         If N is zero, allocate a 1-byte block.  */
diff --git a/meta/recipes-devtools/flex/flex_2.6.4.bb b/meta/recipes-devtools/flex/flex_2.6.4.bb
index 793a935962..96c596764b 100644
--- a/meta/recipes-devtools/flex/flex_2.6.4.bb
+++ b/meta/recipes-devtools/flex/flex_2.6.4.bb
@@ -19,6 +19,7 @@ SRC_URI = "${GITHUB_BASE_URI}/download/v${PV}/flex-${PV}.tar.gz \
            file://check-funcs.patch \
            file://0001-Emit-no-line-directives-if-gen_line_dirs-is-false.patch \
            file://0001-build-tests-add-missing-parser-scanner-dependencies.patch \
+           file://0001-lib-malloc-declare-malloc-via-stdlib.h.patch \
            "
 
 SRC_URI[md5sum] = "2882e3179748cc9f9c23ec593d6adc8d"
