diff options
author | Nick Wellnhofer <wellnhofer@aevum.de> | 2022-01-25 02:59:40 +0100 |
---|---|---|
committer | Nick Wellnhofer <wellnhofer@aevum.de> | 2022-01-25 03:20:28 +0100 |
commit | a647e430259fc663c63caa502f0cee8c94e2d06d (patch) | |
tree | c9864971f0cc4328b8dbf512ee0e0a8f21fd0a0d /SAX2.c | |
parent | 67c2e78b810f9d0644f8cbd450527b81821c99bd (diff) | |
download | libxml2-a647e430259fc663c63caa502f0cee8c94e2d06d.tar.gz |
Fix casting of line numbers in SAX2.c
The line member is an unsigned short. Avoids integer conversion warnings
with UBSan.
Also use USHRT_MAX instead of hard-coded constant.
Diffstat (limited to 'SAX2.c')
-rw-r--r-- | SAX2.c | 30 |
1 files changed, 15 insertions, 15 deletions
@@ -1623,10 +1623,10 @@ xmlSAX2StartElement(void *ctx, const xmlChar *fullname, const xmlChar **atts) ctxt->nodemem = -1; if (ctxt->linenumbers) { if (ctxt->input != NULL) { - if (ctxt->input->line < 65535) - ret->line = (short) ctxt->input->line; + if (ctxt->input->line < USHRT_MAX) + ret->line = (unsigned short) ctxt->input->line; else - ret->line = 65535; + ret->line = USHRT_MAX; } } @@ -1887,10 +1887,10 @@ skip: if (ctxt->linenumbers) { if (ctxt->input != NULL) { - if (ctxt->input->line < 65535) - ret->line = (short) ctxt->input->line; + if (ctxt->input->line < USHRT_MAX) + ret->line = (unsigned short) ctxt->input->line; else { - ret->line = 65535; + ret->line = USHRT_MAX; if (ctxt->options & XML_PARSE_BIG_LINES) ret->psvi = (void *) (ptrdiff_t) ctxt->input->line; } @@ -2267,10 +2267,10 @@ xmlSAX2StartElementNs(void *ctx, } if (ctxt->linenumbers) { if (ctxt->input != NULL) { - if (ctxt->input->line < 65535) - ret->line = (short) ctxt->input->line; + if (ctxt->input->line < USHRT_MAX) + ret->line = (unsigned short) ctxt->input->line; else - ret->line = 65535; + ret->line = USHRT_MAX; } } @@ -2689,10 +2689,10 @@ xmlSAX2ProcessingInstruction(void *ctx, const xmlChar *target, if (ctxt->linenumbers) { if (ctxt->input != NULL) { - if (ctxt->input->line < 65535) - ret->line = (short) ctxt->input->line; + if (ctxt->input->line < USHRT_MAX) + ret->line = (unsigned short) ctxt->input->line; else - ret->line = 65535; + ret->line = USHRT_MAX; } } if (ctxt->inSubset == 1) { @@ -2749,10 +2749,10 @@ xmlSAX2Comment(void *ctx, const xmlChar *value) if (ret == NULL) return; if (ctxt->linenumbers) { if (ctxt->input != NULL) { - if (ctxt->input->line < 65535) - ret->line = (short) ctxt->input->line; + if (ctxt->input->line < USHRT_MAX) + ret->line = (unsigned short) ctxt->input->line; else - ret->line = 65535; + ret->line = USHRT_MAX; } } |