瀏覽代碼

gh-342 - Fix order of evaluation issue in libxml xslprocessor include handling

Fixes gh-342. Order of evaluation can cause MemoryBuffer::detach to be called
before MemoryBuffer::length, ending up with a length of 0.  This caused the
Xalan compiler to think the include was loaded, but completely empty, and
results in an Exception being thrown that is not informative.

I don't think this code path was exercised by previous include handlers which
were file based.  My include handler for embeded resources needs this
functionality.

I'm currently investigating a possible memory leak, and some xslt cache
issues, but this change is worth applying to the master branch right away,
because it solves an immediate functional issue.

Signed-off-by: Anthony Fishbeck <Anthony.Fishbeck@lexisnexis.com>
Anthony Fishbeck 14 年之前
父節點
當前提交
8c9bfcf3a4
共有 1 個文件被更改,包括 2 次插入1 次删除
  1. 2 1
      system/xmllib/xslprocessor.ipp

+ 2 - 1
system/xmllib/xslprocessor.ipp

@@ -133,7 +133,8 @@ public:
             }
             else
             {
-                MemBufInputSource* memsrc = new MemBufInputSource((const XMLByte*)buf.detach(), buf.length(), (const XMLCh*)NULL, false);
+                size32_t buflen = buf.length();
+                MemBufInputSource* memsrc = new MemBufInputSource((const XMLByte*)buf.detach(), buflen, (const XMLCh*)NULL, false);
                 memsrc->setCopyBufToStream(false);
                 inputsrc = memsrc;
             }