This is an automated email from the ASF dual-hosted git repository.
pjfanning pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/poi-xmlbeans.git
The following commit(s) were added to refs/heads/trunk by this push:
new 7d4d4833 Avoid implicit narrowing compound assignments in SchemaTypeSystemImpl.nextBytes (#129)
7d4d4833 is described below
commit 7d4d4833d606e81a323ad38058747cb54288ccf8
Author: PJ Fanning <pj...@users.noreply.github.com>
AuthorDate: Sun Oct 4 15:31:31 2026 +0100
Avoid implicit narrowing compound assignments in SchemaTypeSystemImpl.nextBytes (#129)
avoid implicit narrowing compound assignments in SchemaTypeSystemImpl.nextBytes
Fixes code-scanning alerts for java/implicit-cast-in-compound-assignment.
Also mix the system-info bytes (not just their index) into the mask, and
index the mask with % rather than & so all mask bytes are used.
Co-authored-by: Claude Opus 5.5 <no...@anthropic.com>
---
.../java/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java b/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java
index 8cad4015..0c7585e5 100644
--- a/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java
+++ b/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java
@@ -595,8 +595,7 @@ public class SchemaTypeSystemImpl extends SchemaTypeLoaderBase implements Schema
byte[] bytes = baos.toByteArray();
for (int i = 0; i < bytes.length; i++) {
int j = i % _mask.length;
- _mask[j] *= (byte) 21;
- _mask[j] += (byte) i;
+ _mask[j] = (byte) (_mask[j] * 21 + bytes[i]);
}
} catch (IOException e) {
XBeanDebug.LOG.atDebug().withThrowable(e).log(e.getMessage());
@@ -606,7 +605,7 @@ public class SchemaTypeSystemImpl extends SchemaTypeLoaderBase implements Schema
}
_random.nextBytes(result);
for (int i = 0; i < result.length; i++) {
- int j = i & _mask.length;
+ int j = i % _mask.length;
result[i] ^= _mask[j];
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org