From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Alex Myczko <tar@debian.org>
Date: May, 14 2026 11:54:27 +0000
Subject: [PATCH] <short summary of the patch>

TODO: Put a short summary on the line above and replace this paragraph
with a longer explanation of this change. Complete the meta-information
with other relevant fields (see below for details). To make it easier, the
information below has been extracted from the changelog. Adjust it or drop
it.

---
The information above should follow the Patch Tagging Guidelines, please
checkout https://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: (upstream|backport|vendor|other), (<patch-url>|commit:<commit-id>)
Bug: <upstream-bugtracker-url>
Bug-<Vendor>: <vendor-bugtracker-url>
Forwarded: (no|not-needed|<patch-forwarded-url>)
Applied-Upstream: <version>, (<commit-url>|commit:<commid-id>)
Reviewed-By: <name and email of someone who approved/reviewed the patch>

--- modplugtools-0.5.6.orig/mp123/modplug123.c
+++ modplugtools-0.5.6/mp123/modplug123.c
@@ -197,6 +197,10 @@ char *getFileData(char *filename, long *
     (*size) = ftell(f);
     rewind(f);
     data = (char*)malloc(*size);
+    if (data == NULL) {
+      fclose(f);
+      return NULL;
+    }
     fread(data, *size, sizeof(char), f);
     fclose(f);
 
@@ -350,7 +354,13 @@ for (song=0; song<nFiles; song++) {
       songsplayed++;
 
     set_keypress();
-    strcpy(songname, ModPlug_GetName(f2));
+    const char *modname = ModPlug_GetName(f2);
+    if (modname != NULL) {
+        strncpy(songname, modname, 41);
+        songname[41] = 0;
+    } else {
+        songname[0] = 0;
+    }
 
     /* if no modplug "name" - use last 41 characters of filename */
     if (strlen(songname)==0) {
