Skip to content

Commit

Permalink
PDFBOX-5645: clone UTC TZ before using, as suggested by Daniel Gredler
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1911610 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
THausherr committed Aug 12, 2023
1 parent b8fbb1d commit 62bba0e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
*/
abstract class TTFDataStream implements Closeable
{
private static final TimeZone TIMEZONE_UTC = TimeZone.getTimeZone("UTC");
private static final TimeZone TIMEZONE_UTC = TimeZone.getTimeZone("UTC"); // clone before using

TTFDataStream()
{
Expand Down Expand Up @@ -210,7 +210,7 @@ public short readSignedShort() throws IOException
public Calendar readInternationalDate() throws IOException
{
long secondsSince1904 = readLong();
Calendar cal = Calendar.getInstance(TIMEZONE_UTC);
Calendar cal = Calendar.getInstance((TimeZone) TIMEZONE_UTC.clone());
cal.set(1904, 0, 1, 0, 0, 0);
cal.set(Calendar.MILLISECOND, 0);
long millisFor1904 = cal.getTimeInMillis();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public final class TTFSubsetter

private static final byte[] PAD_BUF = new byte[] { 0, 0, 0 };

private static final TimeZone TIMEZONE_UTC = TimeZone.getTimeZone("UTC");
private static final TimeZone TIMEZONE_UTC = TimeZone.getTimeZone("UTC"); // clone before using

private final TrueTypeFont ttf;
private final CmapLookup unicodeCmap;
Expand Down Expand Up @@ -1086,7 +1086,7 @@ private void writeUint8(DataOutputStream out, int i) throws IOException
private void writeLongDateTime(DataOutputStream out, Calendar calendar) throws IOException
{
// inverse operation of TTFDataStream.readInternationalDate()
Calendar cal = Calendar.getInstance(TIMEZONE_UTC);
Calendar cal = Calendar.getInstance((TimeZone) TIMEZONE_UTC.clone());
cal.set(1904, 0, 1, 0, 0, 0);
cal.set(Calendar.MILLISECOND, 0);
long millisFor1904 = cal.getTimeInMillis();
Expand Down

0 comments on commit 62bba0e

Please sign in to comment.