From f3f34f21a2614950787c63d49ca8b7e1006b556d Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Wed, 17 Mar 2021 14:04:20 +0300
Subject: [PATCH] timidity: replaced a strncpy() with memcpy(). a few other
cleanups.
---
src/codecs/timidity/common.c | 15 +++++++++------
src/codecs/timidity/common.h | 5 -----
src/codecs/timidity/options.h | 4 ++--
src/codecs/timidity/timidity.h | 4 ++--
4 files changed, 13 insertions(+), 15 deletions(-)
diff --git a/src/codecs/timidity/common.c b/src/codecs/timidity/common.c
index e7a6164..912500b 100644
--- a/src/codecs/timidity/common.c
+++ b/src/codecs/timidity/common.c
@@ -33,7 +33,12 @@
#endif
/* The paths in this list will be tried whenever we're reading a file */
-static PathList *pathlist = NULL; /* This is a linked list */
+typedef struct _PathList {
+ char *path;
+ struct _PathList *next;
+} PathList;
+
+static PathList *pathlist = NULL;
/* This is meant to find and open files for reading */
SDL_RWops *open_file(const char *name)
@@ -106,12 +111,11 @@ void add_to_pathlist(const char *s, size_t l)
return;
plp->path = safe_malloc(l + 1);
- if (plp->path == NULL)
- {
+ if (plp->path == NULL) {
free (plp);
return;
}
- strncpy(plp->path, s, l);
+ memcpy(plp->path, s, l);
plp->path[l] = 0;
plp->next = pathlist;
pathlist = plp;
@@ -122,8 +126,7 @@ void free_pathlist(void)
PathList *plp = pathlist;
PathList *next;
- while (plp)
- {
+ while (plp) {
next = plp->next;
free(plp->path);
free(plp);
diff --git a/src/codecs/timidity/common.h b/src/codecs/timidity/common.h
index 3d46f9f..0b9b97b 100644
--- a/src/codecs/timidity/common.h
+++ b/src/codecs/timidity/common.h
@@ -9,11 +9,6 @@
common.h
*/
-typedef struct {
- char *path;
- void *next;
-} PathList;
-
extern SDL_RWops *open_file(const char *name);
extern void add_to_pathlist(const char *s, size_t len);
extern void *safe_malloc(size_t count);
diff --git a/src/codecs/timidity/options.h b/src/codecs/timidity/options.h
index a8c9c99..bf90771 100644
--- a/src/codecs/timidity/options.h
+++ b/src/codecs/timidity/options.h
@@ -69,8 +69,7 @@
#define MAX_AMPLIFICATION 800
-/* You could specify a complete path, e.g. "/etc/timidity.cfg", and
- then specify the library directory in the configuration file. */
+/* The TiMidity configuration file */
#ifndef TIMIDITY_CFG
#define TIMIDITY_CFG "timidity.cfg"
#endif
@@ -98,4 +97,5 @@
#define PI 3.14159265358979323846
#endif
+/* for very loud debug output: */
#define SNDDBG(X)
diff --git a/src/codecs/timidity/timidity.h b/src/codecs/timidity/timidity.h
index f7bd791..9fb0f20 100644
--- a/src/codecs/timidity/timidity.h
+++ b/src/codecs/timidity/timidity.h
@@ -100,9 +100,9 @@ typedef struct {
Uint8 channel, type, a, b;
} MidiEvent;
-typedef struct {
+typedef struct _MidiEventList {
MidiEvent event;
- void *next;
+ struct _MidiEventList *next;
} MidiEventList;
typedef struct {