Преглед изворни кода

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;
             }