kinow commented on code in PR #254:
URL: https://github.com/apache/commons-imaging/pull/254#discussion_r1342192003
##########
src/main/java/org/apache/commons/imaging/formats/webp/chunks/WebPChunk.java:
##########
@@ -61,22 +74,41 @@ public String getTypeDescription() {
(byte) ((type >> 24) & 0xff)}, StandardCharsets.UTF_8);
}
+ /**
+ * @return the payload size.
+ */
public int getPayloadSize() {
return size;
}
+ /**
+ * @return the chunk size.
+ */
public int getChunkSize() {
// if chunk size is odd, a single padding byte is added
int padding = (size % 2) != 0 ? 1 : 0;
// Chunk FourCC (4 bytes) + Chunk Size (4 bytes) + Chunk Payload (n
bytes) + Padding
- return 4 + 4 + size + padding;
+ int chunkFourCCandSize = 4 + 4;
+ int paddedSize = Math.addExact(size, padding);
+ return Math.addExact(chunkFourCCandSize, paddedSize);
Review Comment:
Have a look if that's what you had in mind :+1: thanks!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]