Commit 39d8be7754 for ffmpeg

commit 39d8be775451d206771424236b02a7e56398fe2c
Author: Michael Niedermayer <michael@niedermayer.cc>
Date:   Thu Oct 15 02:02:02 2026 +0200

    avformat: report a failed allocation of a directory entry name

    The file, ftp and libssh protocols returned the entry without a name
    when duplicating the name failed.

    Assisted-by: Claude

diff --git a/libavformat/file.c b/libavformat/file.c
index bb99198a6a..79c6ed88df 100644
--- a/libavformat/file.c
+++ b/libavformat/file.c
@@ -416,7 +416,7 @@ static int file_read_dir(URLContext *h, AVIODirEntry **next)
     }

     (*next)->name = av_strdup(dir->d_name);
-    return 0;
+    return (*next)->name ? 0 : AVERROR(ENOMEM);
 #else
     return AVERROR(ENOSYS);
 #endif /* HAVE_LSTAT */
diff --git a/libavformat/ftp.c b/libavformat/ftp.c
index 3865177f99..67eecc5661 100644
--- a/libavformat/ftp.c
+++ b/libavformat/ftp.c
@@ -994,7 +994,7 @@ static int64_t ftp_parse_date(const char *date)
 static int ftp_parse_entry_nlst(char *line, AVIODirEntry *next)
 {
     next->name = av_strdup(line);
-    return 0;
+    return next->name ? 0 : AVERROR(ENOMEM);
 }

 static int ftp_parse_entry_mlsd(char *mlsd, AVIODirEntry *next)
@@ -1005,7 +1005,8 @@ static int ftp_parse_entry_mlsd(char *mlsd, AVIODirEntry *next)
     while(fact = av_strtok(p, ";", &saveptr)) {
         p = NULL;
         if (fact[0] == ' ') {
-            next->name = av_strdup(&fact[1]);
+            if (!(next->name = av_strdup(&fact[1])))
+                return AVERROR(ENOMEM);
             continue;
         }
         fact = av_strtok(fact, "=", &value);
diff --git a/libavformat/libssh.c b/libavformat/libssh.c
index 470175924d..2b219a8362 100644
--- a/libavformat/libssh.c
+++ b/libavformat/libssh.c
@@ -420,7 +420,7 @@ static int libssh_read_dir(URLContext *h, AVIODirEntry **next)
         entry->type = AVIO_ENTRY_UNKNOWN;
     }
     sftp_attributes_free(attr);
-    return 0;
+    return entry->name ? 0 : AVERROR(ENOMEM);
 }

 static int libssh_close_dir(URLContext *h)