]> git.sesse.net Git - movit/commitdiff
Fix an off-by-one in shader bundle generation.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 22 Jul 2023 16:45:44 +0000 (18:45 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 22 Jul 2023 16:45:44 +0000 (18:45 +0200)
Non-ASCII characters would inadvertently become two bytes instead of one,
which would (for shaders after that in the bundle) give the wrong offsets
and thus potentially corrupted shaders.

Normally, this wouldn't really be noticed since the first things are
comments and the lasts are #undef, but in some cases, the shader
compilers would complain on suspicious things.

Reported by Stefano Rivera, who also provided a test system for debugging.

make_bundled_shaders.cpp

index 53ce13fac597d37cf69f9bb1781cb88f48bc107b..225d08431d3022a0d9cba99de6b39366def8bc59 100644 (file)
@@ -54,7 +54,7 @@ int main(int argc, char **argv)
                } else if (ch == '\\') {        
                        printf("\\\\");
                } else if (!isprint(ch)) {
-                       printf("\\0%o", ch);
+                       printf("\\%o", ch);
                } else {
                        printf("%c", ch);
                }