[OTS] Fix "continue-stream" handling in the woff2 decoder

(1) When reading the short form of the directory, set the
    compressed length to zero for tables with the continue-stream
    flag set.
(2) Initialize transform_buf outside the main loop since it is
    re-used for continue-streams.

Patch contributed by Zoltan Szabadka (szabadka@google.com)

R=yusukes@chromium.org

Review URL: https://codereview.chromium.org/28363002

git-svn-id: http://ots.googlecode.com/svn/trunk@104 a4e77c2c-9104-11de-800e-5b313e0d2bf3
diff --git a/src/woff2.cc b/src/woff2.cc
index 09e87ad..1181479 100644
--- a/src/woff2.cc
+++ b/src/woff2.cc
@@ -826,6 +826,10 @@
       if (!ReadBase128(file, &src_length)) {
         return OTS_FAILURE();
       }
+    } else if ((flag_byte >> 6) == kShortFlagsContinue) {
+      // The compressed data for this table is in a previuos table, so we set
+      // the src_length to zero.
+      src_length = 0;
     }
     // Disallow huge numbers (> 1GB) for sanity.
     if (src_length > 1024 * 1024 * 1024 ||
@@ -954,12 +958,12 @@
   }
   std::vector<uint8_t> uncompressed_buf;
   bool continue_valid = false;
+  const uint8_t* transform_buf = NULL;
   for (uint16_t i = 0; i < num_tables; ++i) {
     const Table* table = &tables.at(i);
     uint32_t flags = table->flags;
     const uint8_t* src_buf = data + table->src_offset;
     uint32_t compression_type = flags & kCompressionTypeMask;
-    const uint8_t* transform_buf = NULL;
     size_t transform_length = table->transform_length;
     if ((flags & kWoff2FlagsContinueStream) != 0) {
       if (!continue_valid) {