Skip to content

Commit f63b011

Browse files
committed
xml: Migrate build_entity to ZendMM
1 parent 8e405ca commit f63b011

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

ext/xml/compat.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -319,15 +319,16 @@ comment_handler(void *user, const xmlChar *comment)
319319
}
320320
}
321321

322-
static void
323-
build_entity(const xmlChar *name, size_t len, xmlChar **entity, size_t *entity_len)
322+
static xmlChar *
323+
build_entity(const xmlChar *name, size_t len, size_t *entity_len)
324324
{
325325
*entity_len = len + 2;
326-
*entity = xmlMalloc(*entity_len + 1);
327-
(*entity)[0] = '&';
328-
memcpy(*entity+1, name, len);
329-
(*entity)[len+1] = ';';
330-
(*entity)[*entity_len] = '\0';
326+
xmlChar *entity = emalloc(*entity_len + 1);
327+
entity[0] = '&';
328+
memcpy(entity + 1, name, len);
329+
entity[len + 1] = ';';
330+
entity[*entity_len] = '\0';
331+
return entity;
331332
}
332333

333334
static void
@@ -362,12 +363,11 @@ get_entity(void *user, const xmlChar *name)
362363
if (ret == NULL || ret->etype == XML_INTERNAL_GENERAL_ENTITY || ret->etype == XML_INTERNAL_PARAMETER_ENTITY || ret->etype == XML_INTERNAL_PREDEFINED_ENTITY) {
363364
/* Predefined entities will expand unless no cdata handler is present */
364365
if (parser->h_default && ! (ret && ret->etype == XML_INTERNAL_PREDEFINED_ENTITY && parser->h_cdata)) {
365-
xmlChar *entity;
366366
size_t len;
367367

368-
build_entity(name, (size_t) xmlStrlen(name), &entity, &len);
368+
xmlChar *entity = build_entity(name, (size_t) xmlStrlen(name), &len);
369369
parser->h_default(parser->user, (const xmlChar *) entity, len);
370-
xmlFree(entity);
370+
efree(entity);
371371
} else {
372372
/* expat will not expand internal entities if default handler is present otherwise
373373
it will expand and pass them to cdata handler */

0 commit comments

Comments
 (0)