santuario-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From blaut...@apache.org
Subject cvs commit: xml-security/c/src/transformers TXFMC14n.cpp
Date Mon, 17 Feb 2003 11:23:38 GMT
blautenb    2003/02/17 03:23:38

  Modified:    c/src/dsig DSIGReference.cpp DSIGTransformC14n.cpp
                        DSIGTransformXPath.cpp
               c/src/transformers TXFMC14n.cpp
  Log:
  Bug fixes for memory leaks caused by exceptions
  
  Revision  Changes    Path
  1.5       +9 -3      xml-security/c/src/dsig/DSIGReference.cpp
  
  Index: DSIGReference.cpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/dsig/DSIGReference.cpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DSIGReference.cpp	12 Feb 2003 11:21:03 -0000	1.4
  +++ DSIGReference.cpp	17 Feb 2003 11:23:38 -0000	1.5
  @@ -961,9 +961,15 @@
   
   	for (i = 0; i < size; ++i) {
   	
  -		nextTxfm = lst->item(i)->createTransformer(txfm);
  -		// nextTxfm->setInput(txfm);
  -		txfm = nextTxfm;
  +		try {
  +			nextTxfm = lst->item(i)->createTransformer(txfm);
  +			// nextTxfm->setInput(txfm);
  +			txfm = nextTxfm;
  +		}
  +		catch (...) {
  +			deleteTXFMChain(txfm);
  +			throw;
  +		}
   
   	}
   
  
  
  
  1.3       +6 -0      xml-security/c/src/dsig/DSIGTransformC14n.cpp
  
  Index: DSIGTransformC14n.cpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/dsig/DSIGTransformC14n.cpp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DSIGTransformC14n.cpp	9 Feb 2003 11:13:48 -0000	1.2
  +++ DSIGTransformC14n.cpp	17 Feb 2003 11:23:38 -0000	1.3
  @@ -76,7 +76,10 @@
   #include <xsec/framework/XSECError.hpp>
   #include <xsec/dsig/DSIGSignature.hpp>
   
  +#include <xercesc/util/Janitor.hpp>
  +
   XSEC_USING_XERCES(DOMNamedNodeMap);
  +XSEC_USING_XERCES(Janitor);
   
   // --------------------------------------------------------------------------------
   //           Constructors and Destructors
  @@ -117,6 +120,8 @@
   	TXFMC14n * c;
   	
   	XSECnew(c, TXFMC14n(mp_txfmNode->getOwnerDocument()));
  +	Janitor<TXFMC14n> j_c(c);
  +
   	c->setInput(input);
   
   	switch (m_cMethod) {
  @@ -151,6 +156,7 @@
   
   	}
   
  +	j_c.release();
   	return c;
   
   }
  
  
  
  1.3       +7 -1      xml-security/c/src/dsig/DSIGTransformXPath.cpp
  
  Index: DSIGTransformXPath.cpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/dsig/DSIGTransformXPath.cpp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DSIGTransformXPath.cpp	9 Feb 2003 11:13:48 -0000	1.2
  +++ DSIGTransformXPath.cpp	17 Feb 2003 11:23:38 -0000	1.3
  @@ -78,6 +78,10 @@
   #include <xsec/framework/XSECError.hpp>
   #include <xsec/dsig/DSIGSignature.hpp>
   
  +#include <xercesc/util/Janitor.hpp>
  +
  +XSEC_USING_XERCES(Janitor);
  +
   // --------------------------------------------------------------------------------
   //           Constructors and Destructors
   // --------------------------------------------------------------------------------
  @@ -126,10 +130,12 @@
   	TXFMXPath *x;
   	// XPath transform
   	XSECnew(x, TXFMXPath(mp_txfmNode->getOwnerDocument()));
  +	Janitor<TXFMXPath> j_x(x);
   	x->setInput(input);
   	x->setNameSpace(mp_NSMap);
   	x->evaluateExpr(mp_txfmNode, m_expr);
  -
  +	
  +	j_x.release();
   	return x;
   	
   #endif /* NO_XPATH */
  
  
  
  1.3       +17 -4     xml-security/c/src/transformers/TXFMC14n.cpp
  
  Index: TXFMC14n.cpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/transformers/TXFMC14n.cpp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TXFMC14n.cpp	9 Feb 2003 11:13:51 -0000	1.2
  +++ TXFMC14n.cpp	17 Feb 2003 11:23:38 -0000	1.3
  @@ -72,6 +72,8 @@
   
   #include <xsec/transformers/TXFMC14n.hpp>
   #include <xsec/framework/XSECException.hpp>
  +#include <xsec/transformers/TXFMParser.hpp>
  +#include <xsec/framework/XSECError.hpp>
   
   TXFMC14n::TXFMC14n(DOMDocument *doc) : TXFMBase(doc) {
   
  @@ -90,13 +92,24 @@
   
   void TXFMC14n::setInput(TXFMBase *newInput) {
   
  -	if (newInput->getOutputType() != TXFMBase::DOM_NODES) {
  +	if (newInput->getOutputType() == TXFMBase::BYTE_STREAM) {
   
  -		throw XSECException(XSECException::TransformInputOutputFail, "C14n canonicalisation transform
requires DOM_NODES input");
  +		//throw XSECException(XSECException::TransformInputOutputFail, "C14n canonicalisation
transform requires DOM_NODES input");
  +		// Need to parse into DOM_NODES
  +		TXFMParser * parser;
  +		XSECnew(parser, TXFMParser(mp_expansionDoc));
  +		try{
  +			parser->setInput(newInput);
  +		}
  +		catch (...) {
  +			delete parser;
  +			throw;
  +		}
   
  +		input = parser;
   	}
  -
  -	input = newInput;
  +	else
  +		input = newInput;
   
   	// Set up for comments  - by default we ALWAYS strip comments
   
  
  
  

Mime
View raw message