瀏覽代碼

LibGfx/TIFF: Don't include the null-byte terminator when reading strings

Lucas CHOLLET 1 年之前
父節點
當前提交
0a80daef90
共有 1 個文件被更改,包括 3 次插入0 次删除
  1. 3 0
      Userland/Libraries/LibGfx/ImageFormats/TIFFLoader.cpp

+ 3 - 0
Userland/Libraries/LibGfx/ImageFormats/TIFFLoader.cpp

@@ -378,6 +378,9 @@ private:
         case Type::ASCII:
         case Type::UTF8: {
             Vector<Value, 1> result;
+            // NOTE: No need to include the null terminator
+            if (count > 0)
+                --count;
             auto string_data = TRY(ByteBuffer::create_uninitialized(count));
             TRY(m_stream->read_until_filled(string_data));
             result.empend(TRY(String::from_utf8(StringView { string_data.bytes() })));