DanRuta/GPGPU

Double free in compileShader

Closed this issue · 2 comments

If an array is allocated in a scope on stack it will be freed upon scope's end. Also freeing stack allocated memory is UB.
This code is the culprit:

if (infoLen > 1) {

    char infoLog[infoLen];

    // And print them out
    glGetShaderInfoLog(shader, infoLen, NULL, infoLog);
    printf("%s\n", infoLog);

    free(infoLog);
}

I opened a PR to fix it #1

Thank you for the tip (and the PR). It's been some years since I've worked with this, so I'll take your word for it that there's no memory leaks. Let me know if you find out otherwise.

Thanks for the library! I am developing a GPGPU application for SGX GPU's and your code is a good learning material (well structured GL calls and good function splitting).
As for the memory leak, trust in the standard 😄