[shibboleth-sp2] 81/119: Fix improper uses of delete and free.
Ferenc Wágner
wferi-guest at moszumanska.debian.org
Tue Jan 26 21:29:52 UTC 2016
This is an automated email from the git hooks/post-receive script.
wferi-guest pushed a commit to annotated tag 1.3.1
in repository shibboleth-sp2.
commit de98267d300e8f1f53da2d1099f5926bb810387f
Author: Scott Cantor <cantor.2 at osu.edu>
Date: Tue Oct 2 15:22:58 2007 +0000
Fix improper uses of delete and free.
---
xmlproviders/XMLCredentials.cpp | 8 ++++--
xmlproviders/XMLMetadata.cpp | 63 +++++++++++++++++++++++++----------------
2 files changed, 43 insertions(+), 28 deletions(-)
diff --git a/xmlproviders/XMLCredentials.cpp b/xmlproviders/XMLCredentials.cpp
index 98146b4..57f00f9 100644
--- a/xmlproviders/XMLCredentials.cpp
+++ b/xmlproviders/XMLCredentials.cpp
@@ -94,7 +94,7 @@ void XMLCredentialsImpl::init()
DOMElement* child=saml::XML::getFirstChildElement(m_root);
while (child) {
string cr_type;
- auto_ptr<char> id(XMLString::transcode(child->getAttributeNS(NULL,SHIB_L(Id))));
+ auto_ptr_char id(child->getAttributeNS(NULL,SHIB_L(Id)));
if (saml::XML::isElementNamed(child,::XML::CREDS_NS,SHIB_L(FileResolver)))
cr_type="edu.internet2.middleware.shibboleth.common.Credentials.FileCredentialResolver";
@@ -129,13 +129,15 @@ void XMLCredentialsImpl::init()
}
catch (SAMLException& e) {
log.errorStream() << "Error while parsing creds configuration: " << e.what() << CategoryStream::ENDLINE;
- this->~XMLCredentialsImpl();
+ for (resolvermap_t::iterator j=m_resolverMap.begin(); j!=m_resolverMap.end(); j++)
+ delete j->second;
throw;
}
#ifndef _DEBUG
catch (...) {
log.error("Unexpected error while parsing creds configuration");
- this->~XMLCredentialsImpl();
+ for (resolvermap_t::iterator j=m_resolverMap.begin(); j!=m_resolverMap.end(); j++)
+ delete j->second;
throw;
}
#endif
diff --git a/xmlproviders/XMLMetadata.cpp b/xmlproviders/XMLMetadata.cpp
index 0b61065..d6d59b8 100644
--- a/xmlproviders/XMLMetadata.cpp
+++ b/xmlproviders/XMLMetadata.cpp
@@ -53,12 +53,16 @@ namespace {
{
public:
ContactPerson(const DOMElement* e);
- ~ContactPerson() {}
+ ~ContactPerson() {
+ delete[] m_givenName;
+ delete[] m_surName;
+ delete[] m_company;
+ }
ContactType getType() const { return m_type; }
- const char* getCompany() const { return m_company.get(); }
- const char* getGivenName() const { return m_givenName.get(); }
- const char* getSurName() const { return m_surName.get(); }
+ const char* getCompany() const { return m_company; }
+ const char* getGivenName() const { return m_givenName; }
+ const char* getSurName() const { return m_surName; }
Iterator<string> getEmailAddresses() const { return m_emails; }
Iterator<string> getTelephoneNumbers() const { return m_phones; }
const DOMElement* getElement() const { return m_root; }
@@ -66,7 +70,9 @@ namespace {
private:
const DOMElement* m_root;
ContactType m_type;
- auto_ptr<char> m_givenName,m_surName,m_company;
+ char* m_givenName;
+ char* m_surName;
+ char* m_company;
vector<string> m_emails,m_phones;
};
@@ -354,13 +360,13 @@ namespace {
const DOMElement* getElement() const {return m_root;}
// Used internally
- const char* getErrorURL() const {return m_errorURL.get();}
+ const char* getErrorURL() const {return m_errorURL;}
time_t getValidUntil() const {return m_validUntil;}
private:
const DOMElement* m_root;
const IEntitiesDescriptor* m_parent;
const XMLCh* m_id;
- auto_ptr<char> m_errorURL;
+ char* m_errorURL;
IOrganization* m_org;
vector<const IContactPerson*> m_contacts;
vector<const IRoleDescriptor*> m_roles;
@@ -467,11 +473,12 @@ XMLMetadataImpl::ContactPerson::ContactPerson(const DOMElement* e) : m_root(e),
// Old metadata or new?
if (saml::XML::isElementNamed(e,::XML::SHIB_NS,SHIB_L(Contact))) {
type=e->getAttributeNS(NULL,SHIB_L(Type));
- m_surName=auto_ptr<char>(toUTF8(e->getAttributeNS(NULL,SHIB_L(Name))));
+ m_surName=toUTF8(e->getAttributeNS(NULL,SHIB_L(Name)));
if (e->hasAttributeNS(NULL,SHIB_L(Email))) {
- auto_ptr<char> temp(toUTF8(e->getAttributeNS(NULL,SHIB_L(Email))));
- if (temp.get())
- m_emails.push_back(temp.get());
+ char* temp = toUTF8(e->getAttributeNS(NULL,SHIB_L(Email)));
+ if (temp)
+ m_emails.push_back(temp);
+ delete[] temp;
}
}
else if (saml::XML::isElementNamed(e,::XML::SAML2META_NS,SHIB_L(ContactPerson))) {
@@ -481,28 +488,30 @@ XMLMetadataImpl::ContactPerson::ContactPerson(const DOMElement* e) : m_root(e),
while (e) {
if (saml::XML::isElementNamed(e,::XML::SAML2META_NS,SHIB_L(Company))) {
n=e->getFirstChild();
- if (n) m_company=auto_ptr<char>(toUTF8(n->getNodeValue()));
+ if (n) m_company=toUTF8(n->getNodeValue());
}
else if (saml::XML::isElementNamed(e,::XML::SAML2META_NS,SHIB_L(GivenName))) {
n=e->getFirstChild();
- if (n) m_givenName=auto_ptr<char>(toUTF8(n->getNodeValue()));
+ if (n) m_givenName=toUTF8(n->getNodeValue());
}
else if (saml::XML::isElementNamed(e,::XML::SAML2META_NS,SHIB_L(SurName))) {
n=e->getFirstChild();
- if (n) m_surName=auto_ptr<char>(toUTF8(n->getNodeValue()));
+ if (n) m_surName=toUTF8(n->getNodeValue());
}
else if (saml::XML::isElementNamed(e,::XML::SAML2META_NS,SHIB_L(EmailAddress))) {
n=e->getFirstChild();
if (n) {
- auto_ptr<char> temp(toUTF8(n->getNodeValue()));
- if (temp.get()) m_emails.push_back(temp.get());
+ char* temp = toUTF8(n->getNodeValue());
+ if (temp) m_emails.push_back(temp);
+ delete[] temp;
}
}
else if (saml::XML::isElementNamed(e,::XML::SAML2META_NS,SHIB_L(TelephoneNumber))) {
n=e->getFirstChild();
if (n) {
- auto_ptr<char> temp(toUTF8(n->getNodeValue()));
- if (temp.get()) m_phones.push_back(temp.get());
+ char* temp = toUTF8(n->getNodeValue());
+ if (temp) m_phones.push_back(temp);
+ delete[] temp;
}
}
e=saml::XML::getNextSiblingElement(e);
@@ -527,25 +536,28 @@ XMLMetadataImpl::Organization::Organization(const DOMElement* e) : m_root(e)
if (saml::XML::isElementNamed(e,::XML::SAML2META_NS,SHIB_L(OrganizationName))) {
n=e->getFirstChild();
if (n) {
- auto_ptr<char> name(toUTF8(n->getNodeValue()));
+ char* name = toUTF8(n->getNodeValue());
auto_ptr_char lang(e->getAttributeNS(saml::XML::XML_NS,L(lang)));
- m_names[lang.get()]=name.get();
+ m_names[lang.get()]=name;
+ delete[] name;
}
}
else if (saml::XML::isElementNamed(e,::XML::SAML2META_NS,SHIB_L(OrganizationDisplayName))) {
n=e->getFirstChild();
if (n) {
- auto_ptr<char> display(toUTF8(n->getNodeValue()));
+ char* display = toUTF8(n->getNodeValue());
auto_ptr_char lang(e->getAttributeNS(saml::XML::XML_NS,L(lang)));
- m_displays[lang.get()]=display.get();
+ m_displays[lang.get()]=display;
+ delete[] display;
}
}
else if (saml::XML::isElementNamed(e,::XML::SAML2META_NS,SHIB_L(OrganizationURL))) {
n=e->getFirstChild();
if (n) {
- auto_ptr<char> url(toUTF8(n->getNodeValue()));
+ char* url = toUTF8(n->getNodeValue());
auto_ptr_char lang(e->getAttributeNS(saml::XML::XML_NS,L(lang)));
- m_urls[lang.get()]=url.get();
+ m_urls[lang.get()]=url;
+ delete[] url;
}
}
e=saml::XML::getNextSiblingElement(e);
@@ -1005,7 +1017,7 @@ XMLMetadataImpl::EntityDescriptor::EntityDescriptor(
}
else {
m_id=e->getAttributeNS(NULL,SHIB_L(Name));
- m_errorURL=auto_ptr<char>(toUTF8(e->getAttributeNS(NULL,SHIB_L(ErrorURL))));
+ m_errorURL=toUTF8(e->getAttributeNS(NULL,SHIB_L(ErrorURL)));
bool idp=false,aa=false; // only want to build a role once
DOMElement* child=saml::XML::getFirstChildElement(e);
@@ -1076,6 +1088,7 @@ const IAttributeAuthorityDescriptor* XMLMetadataImpl::EntityDescriptor::getAttri
XMLMetadataImpl::EntityDescriptor::~EntityDescriptor()
{
+ delete[] m_errorURL;
delete m_org;
for (vector<const IContactPerson*>::iterator i=m_contacts.begin(); i!=m_contacts.end(); i++)
delete const_cast<IContactPerson*>(*i);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-shibboleth/shibboleth-sp2.git
More information about the Pkg-shibboleth-devel
mailing list