diff options
author | Chris Robinson <[email protected]> | 2014-04-09 20:14:45 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2014-04-09 20:14:45 -0700 |
commit | 023981acb9242649f1fff8b02143a26e85005a9f (patch) | |
tree | 81b73c2e4dcb3fa7e35b18947b0a0258f00c0e81 /Alc/midi/sf2load.c | |
parent | 1290f37750486d9f036d436ea9e397cbfd24fb13 (diff) |
Fix a NULL deref when cloning a 0-sized vector
Diffstat (limited to 'Alc/midi/sf2load.c')
-rw-r--r-- | Alc/midi/sf2load.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/Alc/midi/sf2load.c b/Alc/midi/sf2load.c index 5b7eee4a..1c7cc10b 100644 --- a/Alc/midi/sf2load.c +++ b/Alc/midi/sf2load.c @@ -346,15 +346,20 @@ static void GenModList_Destruct(GenModList *self) static GenModList GenModList_clone(const GenModList *self) { + ALsizei count, i; GenModList ret; GenModList_Construct(&ret); - VECTOR_RESERVE(ret.gens, VECTOR_CAPACITY(self->gens)); - memcpy(ret.gens, self->gens, sizeof(ret.gens) + - VECTOR_CAPACITY(ret.gens) * sizeof(ret.gens->Data[0])); - VECTOR_RESERVE(ret.mods, VECTOR_CAPACITY(self->mods)); - memcpy(ret.mods, self->mods, sizeof(ret.mods) + - VECTOR_CAPACITY(ret.mods) * sizeof(ret.mods->Data[0])); + + count = VECTOR_SIZE(self->gens); + VECTOR_RESERVE(ret.gens, count); + for(i = 0;i < count;i++) + VECTOR_PUSH_BACK(ret.gens, VECTOR_ELEM(self->gens, i)); + + count = VECTOR_SIZE(self->mods); + VECTOR_RESERVE(ret.mods, count); + for(i = 0;i < count;i++) + VECTOR_PUSH_BACK(ret.mods, VECTOR_ELEM(self->mods, i)); return ret; } |