From 1b30908f41ef7a9da29e37c51d839c56928d5984 Mon Sep 17 00:00:00 2001 From: Jason Edward Stewart <jasons@apache.org> Date: Mon, 28 Aug 2006 10:58:06 +0000 Subject: [PATCH] removed memory leak from transcode() git-svn-id: https://svn.apache.org/repos/asf/xerces/c/trunk@437650 13f79535-47bb-0310-9956-ffa450edef68 --- swig/perl/Handler/PerlEntityResolverHandler.i | 20 ++----------------- 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/swig/perl/Handler/PerlEntityResolverHandler.i b/swig/perl/Handler/PerlEntityResolverHandler.i index 799f64882..826b8b67c 100644 --- a/swig/perl/Handler/PerlEntityResolverHandler.i +++ b/swig/perl/Handler/PerlEntityResolverHandler.i @@ -75,21 +75,11 @@ PerlEntityResolverHandler::resolveEntity (const XMLCh* const publicId, XPUSHs(callbackObj); // the next argument is the publicId - - // this transcode has two problems 1) it will leak if not deleted - // and 2) why are we getting a char*, doesn't this screw up Unicode? - char *cptr1 = XMLString::transcode(publicId); - SV *string1 = sv_newmortal(); - sv_setpv(string1, (char *)cptr1); + SV *string1 = XMLString2Perl(publicId); XPUSHs(string1); // the next argument is the systemId - - // this transcode has two problems 1) it will leak if not deleted - // and 2) why are we getting a char*, doesn't this screw up Unicode? - char *cptr2 = XMLString::transcode(systemId); - SV *string2 = sv_newmortal(); - sv_setpv(string2, (char *)cptr2); + SV *string2 = XMLString2Perl(systemId); XPUSHs(string2); PUTBACK; @@ -118,12 +108,6 @@ PerlEntityResolverHandler::resolveEntity (const XMLCh* const publicId, croak("EntityResolver did not return an InputSource. Expected %s", SWIGTYPE_p_XERCES_CPP_NAMESPACE__InputSource->name); } PUTBACK ; - - - // transcode mallocs this and leaves it up to us to free the memory - delete [] cptr1; - delete [] cptr2; - FREETMPS; LEAVE; return source; -- GitLab