summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/midifile.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/midifile.c b/src/midifile.c
index 00ff28d4..cb366774 100644
--- a/src/midifile.c
+++ b/src/midifile.c
@@ -176,9 +176,10 @@ static void *ReadByteSequence(unsigned int num_bytes, FILE *stream)
unsigned int i;
byte *result;
- // Allocate a buffer:
+ // Allocate a buffer. Allocate one extra byte, as malloc(0) is
+ // non-portable.
- result = malloc(num_bytes);
+ result = malloc(num_bytes + 1);
if (result == NULL)
{