OpenAL Soft crashes in release mode (debug works fine)
<p>I have created a small sample program in C++ trying to play sounds with OpenAL Soft. The program crashes when compiled in release mode, when compiled in debug mode it works. I'm on OS X using 1.17.2.</p>

<p>I get this error message: </p>

<blockquote>
  <p>SoundTest(28958,0x70000021d000) malloc: *** error for object 0x7fbdd26062c8: incorrect checksum for freed object - object was probably modified after being freed.</p>
</blockquote>

<p>This is the full sample program:</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;AL/alc.h&gt;
#include &lt;AL/al.h&gt;
#include &lt;cmath&gt;

using namespace std;

int main() {
    // Reset error state just to be sure
    alGetError();

    ALCdevice *device = alcOpenDevice(NULL);
    if (device == NULL) {
        cout &lt;&lt; "Error creating device" &lt;&lt; endl;
        return 1;
    }

    ALCcontext *context = alcCreateContext(device, NULL);
    if (!alcMakeContextCurrent(context)) {
        cout &lt;&lt; "Failed to make context current" &lt;&lt; endl;
        return 1;
    }

    ALuint buffer;

    // Set up sound buffer
    alGenBuffers((ALuint)1, &amp;buffer);

    // Fill buffer with sine-wave
    float freq = 440.f;
    int seconds = 4;
    unsigned sample_rate = 22050;
    size_t buf_size = seconds * sample_rate;

    short *samples;
    samples = new short[buf_size];
    for(int i=0; i&lt;buf_size; ++i) {
        samples[i] = (short) (32760 * sin((2.f * float(M_PI) * freq) / sample_rate * i ));
    }

    alBufferData(buffer, AL_FORMAT_MONO16, samples, buf_size, sample_rate);

    ALuint source;

    // Set up sound source
    alGenSources((ALuint)1, &amp;source);
    alSourcef(source, AL_PITCH, 1);
    alSourcef(source, AL_GAIN, 1);
    alSource3f(source, AL_POSITION, 0, 0, 0);
    alSource3f(source, AL_VELOCITY, 0, 0, 0);
    alSourcei(source, AL_LOOPING, AL_FALSE);
    alSourcei(source, AL_BUFFER, buffer);

    // Start playing
    alSourcePlay(source);

    // Wait until the sound stops playing
    ALenum state;
    do {
        alGetSourcei(source, AL_SOURCE_STATE, &amp;state);
    } while (state == AL_PLAYING);

    // Clean up
    alDeleteSources(1, &amp;source);
    alcMakeContextCurrent(NULL);
    alcDestroyContext(context);
    alcCloseDevice(device);

    return 0;
}
</code></pre>