From 063edfcc4a3d0ca5632d84910b3181d3bc81ed88 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sat, 4 Aug 2018 05:22:40 +0900 Subject: [PATCH] opengl: Use the safer way to pass Go string to C --- internal/opengl/context_desktop.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/opengl/context_desktop.go b/internal/opengl/context_desktop.go index 065a77003..7fde3698f 100644 --- a/internal/opengl/context_desktop.go +++ b/internal/opengl/context_desktop.go @@ -366,7 +366,9 @@ func (c *Context) DeleteProgram(p Program) { } func (c *Context) getUniformLocationImpl(p Program, location string) uniformLocation { - uniform := uniformLocation(gl.GetUniformLocation(uint32(p), gl.Str(location+"\x00"))) + l, free := gl.Strs(location + "\x00") + uniform := uniformLocation(gl.GetUniformLocation(uint32(p), *l)) + free() if uniform == -1 { panic("opengl: invalid uniform location: " + location) } @@ -407,7 +409,9 @@ func (c *Context) UniformFloats(p Program, location string, v []float32) { } func (c *Context) getAttribLocationImpl(p Program, location string) attribLocation { - attrib := attribLocation(gl.GetAttribLocation(uint32(p), gl.Str(location+"\x00"))) + l, free := gl.Strs(location + "\x00") + attrib := attribLocation(gl.GetAttribLocation(uint32(p), *l)) + free() if attrib == -1 { panic("opengl: invalid attrib location: " + location) }