Skip to content

Use size_t for string lengths in ext/xml compat layer #12808

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions ext/xml/compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ _notation_decl_handler(void *user, const xmlChar *notation, const xmlChar *pub_i
}

static void
_build_comment(const xmlChar *data, int data_len, xmlChar **comment, int *comment_len)
_build_comment(const xmlChar *data, size_t data_len, xmlChar **comment, size_t *comment_len)
{
*comment_len = data_len + 7;

Expand All @@ -330,16 +330,16 @@ _comment_handler(void *user, const xmlChar *comment)

if (parser->h_default) {
xmlChar *d_comment;
int d_comment_len;
size_t d_comment_len;

_build_comment(comment, xmlStrlen(comment), &d_comment, &d_comment_len);
_build_comment(comment, (size_t) xmlStrlen(comment), &d_comment, &d_comment_len);
parser->h_default(parser->user, d_comment, d_comment_len);
xmlFree(d_comment);
}
}

static void
_build_entity(const xmlChar *name, int len, xmlChar **entity, int *entity_len)
_build_entity(const xmlChar *name, size_t len, xmlChar **entity, size_t *entity_len)
{
*entity_len = len + 2;
*entity = xmlMalloc(*entity_len + 1);
Expand Down Expand Up @@ -380,9 +380,9 @@ _get_entity(void *user, const xmlChar *name)
/* Predefined entities will expand unless no cdata handler is present */
if (parser->h_default && ! (ret && ret->etype == XML_INTERNAL_PREDEFINED_ENTITY && parser->h_cdata)) {
xmlChar *entity;
int len;
size_t len;

_build_entity(name, xmlStrlen(name), &entity, &len);
_build_entity(name, (size_t) xmlStrlen(name), &entity, &len);
parser->h_default(parser->user, (const xmlChar *) entity, len);
xmlFree(entity);
} else {
Expand Down