[libxml2] Fix casting of line numbers in SAX2.c
- From: Nick Wellnhofer <nwellnhof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libxml2] Fix casting of line numbers in SAX2.c
- Date: Tue, 25 Jan 2022 02:35:14 +0000 (UTC)
commit a647e430259fc663c63caa502f0cee8c94e2d06d
Author: Nick Wellnhofer <wellnhofer aevum de>
Date: Tue Jan 25 02:59:40 2022 +0100
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.
SAX2.c | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)
---
diff --git a/SAX2.c b/SAX2.c
index 8c0084c6..03192465 100644
--- a/SAX2.c
+++ b/SAX2.c
@@ -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;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]