Bläddra i källkod

LibPDF/CFF: Fix off-by-one when reading internal encoding

We use `i - 1` to index these arrays, so that's what we should use
for the bounds check as well.
Nico Weber 1 år sedan
förälder
incheckning
4705d38fa7
1 ändrade filer med 2 tillägg och 1 borttagningar
  1. 2 1
      Userland/Libraries/LibPDF/Fonts/CFF.cpp

+ 2 - 1
Userland/Libraries/LibPDF/Fonts/CFF.cpp

@@ -279,8 +279,9 @@ PDFErrorOr<NonnullRefPtr<CFF>> CFF::create(ReadonlyBytes const& cff_bytes, RefPt
                 encoding->set(0, ".notdef");
                 encoding->set(0, ".notdef");
                 continue;
                 continue;
             }
             }
-            if (i >= encoding_codes.size() || i >= charset_names.size())
+            if (i - 1 >= encoding_codes.size() || i - 1 >= charset_names.size()) {
                 break;
                 break;
+            }
             auto code = encoding_codes[i - 1];
             auto code = encoding_codes[i - 1];
             auto char_name = charset_names[i - 1];
             auto char_name = charset_names[i - 1];
             encoding->set(code, char_name);
             encoding->set(code, char_name);