Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return string from GetShaderInfoLog may contain garbage? #16

Open
icefoxen opened this issue Jan 14, 2018 · 1 comment
Open

Return string from GetShaderInfoLog may contain garbage? #16

icefoxen opened this issue Jan 14, 2018 · 1 comment

Comments

@icefoxen
Copy link

On https://github.com/bwasty/learn-opengl-rs/blob/master/src/shader.rs#L107 and related code, we have:

gl::GetShaderInfoLog(shader, 1024, ptr::null_mut(), infoLog.as_mut_ptr() as *mut GLchar);
println!("ERROR::SHADER_COMPILATION_ERROR of type: {}\n{}\n \
     -- --------------------------------------------------- -- ",
    type_,
    str::from_utf8(&infoLog).unwrap());
}

GetShaderInfoLog stores a null-terminated string into infoLog, which may contain garbage after the null terminator. str::from_utf8() may fail if the garbage in infoLog contains invalid unicode values.

@mik30s
Copy link

mik30s commented Mar 8, 2018

use str::from_utf8_unchecked()

Its not safe but it works for now. In the future i would look for the earliest null terminator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants