Skip to content

Return string from GetShaderInfoLog may contain garbage?Β #16

@icefoxen

Description

@icefoxen

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions