Skip to content
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

UL values in XML cause NumberFormatException when > 2^31 #600

Closed
ronshapiro7 opened this issue Dec 11, 2019 · 1 comment
Closed

UL values in XML cause NumberFormatException when > 2^31 #600

ronshapiro7 opened this issue Dec 11, 2019 · 1 comment
Assignees
Labels
Milestone

Comments

@ronshapiro7
Copy link

ronshapiro7 commented Dec 11, 2019

Issue #277 changed it to output the UL as an unsigned integer.

However, now when the value is greater than 2^31, it causes a NumberFormatException when reading the XML.

The following 1 line patch fixes the StringUtils to handle the unsigned integer on read:

Index: src/main/java/org/dcm4che3/util/StringUtils.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/main/java/org/dcm4che3/util/StringUtils.java	(date 1576102631000)
+++ src/main/java/org/dcm4che3/util/StringUtils.java	(date 1576102741064)
@@ -195,7 +195,7 @@
 
     public static int parseIS(String s) {
         return s != null && s.length() != 0
-                ? Integer.parseInt(s.charAt(0) == '+' ? s.substring(1) : s)
+                ? (int) Long.parseLong(s.charAt(0) == '+' ? s.substring(1) : s)
                 : 0;
     }
 
@gunterze gunterze self-assigned this Dec 12, 2019
@gunterze gunterze added the bug label Dec 12, 2019
@gunterze gunterze added this to the 5.20.0 milestone Dec 12, 2019
@gunterze
Copy link
Member

Thanks @ronshapiro7

zhongl pushed a commit to iaerac/dcm4che that referenced this issue Apr 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants