]> granicus.if.org Git - php/commitdiff
(xslt: error_print) Fixes a leak when multiple error messages are issued
authorMelvyn Sopacua <msopacua@php.net>
Sat, 5 Oct 2002 14:04:19 +0000 (14:04 +0000)
committerMelvyn Sopacua <msopacua@php.net>
Sat, 5 Oct 2002 14:04:19 +0000 (14:04 +0000)
                    during a transformation.
# It's probably better to wrap this in an internal function, since it's
# easily forgotten.

ext/xslt/sablot.c

index 109e14ecbb2d89592212096953e00ad01e3df908..a4c9778a3b14f21ca9d89b97b89717286327950c 100644 (file)
@@ -1633,6 +1633,10 @@ static MH_ERROR error_print(void *user_data, SablotHandle proc, MH_ERROR code, M
                msgbuf = emalloc((sizeof(msgformat) - 4) + strlen(errmsg) + strlen(errline) + 1);
                sprintf(msgbuf, msgformat, errline, errmsg);
 
+               /* If an old message exists, remove it -> leak */
+               if (XSLT_ERRSTR(handle))
+                       efree(XSLT_ERRSTR(handle));
+
                /* Copy the error message onto the handle for use when 
                   the xslt_error function is called */
                XSLT_ERRSTR(handle) = estrdup(errmsg);