id,summary,reporter,owner,description,type,status,priority,milestone,component,version,resolution,keywords,cc,os,architecture,failure,difficulty,testcase,blockedby,blocking,related
2549,Non null-terminated C strings sended to OpenGL functions.,Vincent.B,," * Program started with GHC started like runhaskell does
 * debuggued with gDEBugger (OpenGL debug)

Consider the following code :
{{{
borderBind <- get $ programVars ""borderColor""
shadowBind <- get $ programVars ""shadowColor""
mathBind   <- get $ uniformLocation txtProg ""mathAlpha""
alphaBind  <- get $ uniformLocation txtProg ""genAlpha""
}}}

I'm using it to retrieve the location of some variables in some shaders, the problem is the real value sended to OpenGL :
< see image 1 >

They are not null-terminated, and this way, sending some garbage appended at the end of the string.

I've tested a little work-around :
{{{
borderBind <- get $ programVars ""borderColor\0""
shadowBind <- get $ programVars ""shadowColor\0""
mathBind   <- get $ uniformLocation txtProg ""mathAlpha\0""
alphaBind  <- get $ uniformLocation txtProg ""genAlpha\0""
}}}
And this way I'm able to recover the location normally.

<see image2>
----

After digging, the problem seem to be in Graphics.Rendering.OpenGL.GL.Shaders, with the function ''withGLStringLen''. This function is using withCAStringLen which acording to documentation ( [http://haskell.org/ghc/docs/latest/html/libraries/base/Foreign-C-String.html#v%3AwithCAStringLen] ) doesn't provide any assurance about the null termination.
",bug,closed,normal,,libraries/HGL,6.8.3,invalid,,,Windows,x86,,Unknown,,,,
