Bug 1519793 - Avoid writing past the logical length of a string in OGLShaderProgram.cpp. r=jgilbert
authorHenri Sivonen <hsivonen@hsivonen.fi>
Tue, 15 Jan 2019 00:58:55 +0000
changeset 513896 d5245076458f441cbd812737fdb5d515d6bc20de
parent 513895 5e9dc7f35bcf23c6c0215f423a6fd074aea5e416
child 513897 7e9a290c0e917ec56c699c53784a648760c4ed9f
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgilbert
bugs1519793
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1519793 - Avoid writing past the logical length of a string in OGLShaderProgram.cpp. r=jgilbert Differential Revision: https://phabricator.services.mozilla.com/D16440
gfx/layers/opengl/OGLShaderProgram.cpp
--- a/gfx/layers/opengl/OGLShaderProgram.cpp
+++ b/gfx/layers/opengl/OGLShaderProgram.cpp
@@ -889,19 +889,19 @@ GLint ShaderProgramOGL::CreateShader(GLe
    * some whitespace in the log but otherwise leave it empty.
    */
   if (!success
 #ifdef DEBUG
       || (len > 10 && gfxEnv::DebugShaders())
 #endif
   ) {
     nsAutoCString log;
-    log.SetCapacity(len);
+    log.SetLength(len);
     mGL->fGetShaderInfoLog(sh, len, (GLint *)&len, (char *)log.BeginWriting());
-    log.SetLength(len);
+    log.Truncate(len);
 
     if (!success) {
       printf_stderr("=== SHADER COMPILATION FAILED ===\n");
     } else {
       printf_stderr("=== SHADER COMPILATION WARNINGS ===\n");
     }
 
     printf_stderr("=== Source:\n%s\n", aShaderSource);