From 15a9915bfdf772f03656b088737ace80739094fd Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Wed, 7 Jan 2009 21:19:30 -0800 Subject: [PATCH] Make a copy of each device string for the device list --- src/alure.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/alure.cpp b/src/alure.cpp index 7793c87..6c835e5 100644 --- a/src/alure.cpp +++ b/src/alure.cpp @@ -239,8 +239,13 @@ ALURE_API const ALCchar** ALURE_APIENTRY alureGetDeviceNames(ALCboolean all, ALC cur = list; while(*cur) { - retlist[retlistLen] = cur; - cur += strlen(cur)+1; + ALCuint len = strlen(cur)+1; + ALCchar *newstr = new ALCchar[len]; + + memcpy(newstr, cur, len); + cur += len; + + retlist[retlistLen] = newstr; retlistLen++; } retlist[retlistLen] = NULL; @@ -260,7 +265,12 @@ ALURE_API ALvoid ALURE_APIENTRY alureFreeDeviceNames(const ALCchar **names) { init_alure(); - delete[] names; + if(names) + { + for(ALCuint i = 0;names[i];i++) + delete[] const_cast(names[i]); + delete[] names; + } } -- 2.11.4.GIT