Merge
This commit is contained in:
commit
041bb07b95
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -92,25 +92,38 @@ public class @(BeanClassName)BeanInfo extends javax.swing.SwingBeanInfoBase {
|
||||
/**
|
||||
* @return an icon of the specified kind for @(BeanClassName)
|
||||
*/
|
||||
public Image getIcon(int kind) {
|
||||
public Image getIcon(final int kind) {
|
||||
Image i;
|
||||
switch (kind){
|
||||
case ICON_COLOR_32x32:
|
||||
i = loadImage("beaninfo/images/@(BeanClassName)Color32.gif");
|
||||
return ((i == null) ? loadImage("beaninfo/images/JComponentColor32.gif") : i);
|
||||
i = loadStandardImage("beaninfo/images/@(BeanClassName)Color32.gif");
|
||||
return ((i == null) ? loadStandardImage("beaninfo/images/JComponentColor32.gif") : i);
|
||||
case ICON_COLOR_16x16:
|
||||
i = loadImage("beaninfo/images/@(BeanClassName)Color16.gif");
|
||||
return ((i == null) ? loadImage("beaninfo/images/JComponentColor16.gif") : i);
|
||||
i = loadStandardImage("beaninfo/images/@(BeanClassName)Color16.gif");
|
||||
return ((i == null) ? loadStandardImage("beaninfo/images/JComponentColor16.gif") : i);
|
||||
case ICON_MONO_32x32:
|
||||
i = loadImage("beaninfo/images/@(BeanClassName)Mono32.gif");
|
||||
return ((i == null) ? loadImage("beaninfo/images/JComponentMono32.gif") : i);
|
||||
i = loadStandardImage("beaninfo/images/@(BeanClassName)Mono32.gif");
|
||||
return ((i == null) ? loadStandardImage("beaninfo/images/JComponentMono32.gif") : i);
|
||||
case ICON_MONO_16x16:
|
||||
i = loadImage("beaninfo/images/@(BeanClassName)Mono16.gif");
|
||||
return ((i == null) ? loadImage("beaninfo/images/JComponentMono16.gif") : i);
|
||||
i = loadStandardImage("beaninfo/images/@(BeanClassName)Mono16.gif");
|
||||
return ((i == null) ? loadStandardImage("beaninfo/images/JComponentMono16.gif") : i);
|
||||
default:
|
||||
return super.getIcon(kind);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a utility method to help in loading standard icon images.
|
||||
*
|
||||
* @param resourceName A pathname relative to the directory holding the
|
||||
* class file of the current class
|
||||
* @return an image object. May be null if the load failed.
|
||||
* @see java.beans.SimpleBeanInfo#loadImage(String)
|
||||
*/
|
||||
private Image loadStandardImage(final String resourceName) {
|
||||
return java.security.AccessController.doPrivileged(
|
||||
(java.security.PrivilegedAction<Image>) () -> loadImage(resourceName));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -350,7 +350,7 @@ public final class RSACipher extends CipherSpi {
|
||||
switch (mode) {
|
||||
case MODE_SIGN:
|
||||
data = padding.pad(buffer, 0, bufOfs);
|
||||
return RSACore.rsa(data, privateKey);
|
||||
return RSACore.rsa(data, privateKey, true);
|
||||
case MODE_VERIFY:
|
||||
byte[] verifyBuffer = RSACore.convert(buffer, 0, bufOfs);
|
||||
data = RSACore.rsa(verifyBuffer, publicKey);
|
||||
@ -360,7 +360,7 @@ public final class RSACipher extends CipherSpi {
|
||||
return RSACore.rsa(data, publicKey);
|
||||
case MODE_DECRYPT:
|
||||
byte[] decryptBuffer = RSACore.convert(buffer, 0, bufOfs);
|
||||
data = RSACore.rsa(decryptBuffer, privateKey);
|
||||
data = RSACore.rsa(decryptBuffer, privateKey, false);
|
||||
return padding.unpad(data);
|
||||
default:
|
||||
throw new AssertionError("Internal error");
|
||||
|
@ -28,6 +28,7 @@ package java.lang.ref;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.security.AccessController;
|
||||
import sun.misc.JavaLangAccess;
|
||||
import sun.misc.ManagedLocalsThread;
|
||||
import sun.misc.SharedSecrets;
|
||||
import sun.misc.VM;
|
||||
|
||||
@ -126,7 +127,7 @@ final class Finalizer extends FinalReference<Object> { /* Package-private; must
|
||||
for (ThreadGroup tgn = tg;
|
||||
tgn != null;
|
||||
tg = tgn, tgn = tg.getParent());
|
||||
Thread sft = new Thread(tg, proc, "Secondary finalizer");
|
||||
Thread sft = new ManagedLocalsThread(tg, proc, "Secondary finalizer");
|
||||
sft.start();
|
||||
try {
|
||||
sft.join();
|
||||
@ -185,7 +186,7 @@ final class Finalizer extends FinalReference<Object> { /* Package-private; must
|
||||
}}});
|
||||
}
|
||||
|
||||
private static class FinalizerThread extends Thread {
|
||||
private static class FinalizerThread extends ManagedLocalsThread {
|
||||
private volatile boolean running;
|
||||
FinalizerThread(ThreadGroup g) {
|
||||
super(g, "Finalizer");
|
||||
|
@ -27,6 +27,7 @@ package java.lang.ref;
|
||||
|
||||
import sun.misc.Cleaner;
|
||||
import sun.misc.JavaLangRefAccess;
|
||||
import sun.misc.ManagedLocalsThread;
|
||||
import sun.misc.SharedSecrets;
|
||||
|
||||
/**
|
||||
@ -126,7 +127,7 @@ public abstract class Reference<T> {
|
||||
|
||||
/* High-priority thread to enqueue pending References
|
||||
*/
|
||||
private static class ReferenceHandler extends Thread {
|
||||
private static class ReferenceHandler extends ManagedLocalsThread {
|
||||
|
||||
private static void ensureClassInitialized(Class<?> clazz) {
|
||||
try {
|
||||
|
@ -82,8 +82,7 @@ public class GC {
|
||||
*/
|
||||
public static native long maxObjectInspectionAge();
|
||||
|
||||
|
||||
private static class Daemon extends Thread {
|
||||
private static class Daemon extends ManagedLocalsThread {
|
||||
|
||||
public void run() {
|
||||
for (;;) {
|
||||
|
@ -26,32 +26,37 @@
|
||||
package sun.misc;
|
||||
|
||||
import java.security.AccessControlContext;
|
||||
import java.security.AccessController;
|
||||
import java.security.ProtectionDomain;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
* A thread that has no permissions, is not a member of any user-defined
|
||||
* ThreadGroup and supports the ability to erase ThreadLocals.
|
||||
*
|
||||
* @implNote Based on the implementation of InnocuousForkJoinWorkerThread.
|
||||
*/
|
||||
public final class InnocuousThread extends Thread {
|
||||
public final class InnocuousThread extends ManagedLocalsThread {
|
||||
private static final Unsafe UNSAFE;
|
||||
private static final ThreadGroup THREADGROUP;
|
||||
private static final ThreadGroup INNOCUOUSTHREADGROUP;
|
||||
private static final AccessControlContext ACC;
|
||||
private static final long THREADLOCALS;
|
||||
private static final long INHERITABLETHREADLOCALS;
|
||||
private static final long INHERITEDACCESSCONTROLCONTEXT;
|
||||
private static final long CONTEXTCLASSLOADER;
|
||||
|
||||
private static final AtomicInteger threadNumber = new AtomicInteger(1);
|
||||
|
||||
public InnocuousThread(Runnable target) {
|
||||
super(THREADGROUP, target, "anInnocuousThread");
|
||||
UNSAFE.putOrderedObject(this, INHERITEDACCESSCONTROLCONTEXT, ACC);
|
||||
eraseThreadLocals();
|
||||
this(INNOCUOUSTHREADGROUP, target,
|
||||
"InnocuousThread-" + threadNumber.getAndIncrement());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassLoader getContextClassLoader() {
|
||||
// always report system class loader
|
||||
return ClassLoader.getSystemClassLoader();
|
||||
public InnocuousThread(Runnable target, String name) {
|
||||
this(INNOCUOUSTHREADGROUP, target, name);
|
||||
}
|
||||
|
||||
public InnocuousThread(ThreadGroup group, Runnable target, String name) {
|
||||
super(group, target, name);
|
||||
UNSAFE.putOrderedObject(this, INHERITEDACCESSCONTROLCONTEXT, ACC);
|
||||
UNSAFE.putOrderedObject(this, CONTEXTCLASSLOADER, ClassLoader.getSystemClassLoader());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -61,7 +66,11 @@ public final class InnocuousThread extends Thread {
|
||||
|
||||
@Override
|
||||
public void setContextClassLoader(ClassLoader cl) {
|
||||
throw new SecurityException("setContextClassLoader");
|
||||
// Allow clearing of the TCCL to remove the reference to the system classloader.
|
||||
if (cl == null)
|
||||
super.setContextClassLoader(null);
|
||||
else
|
||||
throw new SecurityException("setContextClassLoader");
|
||||
}
|
||||
|
||||
// ensure run method is run only once
|
||||
@ -75,14 +84,6 @@ public final class InnocuousThread extends Thread {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Drops all thread locals (and inherited thread locals).
|
||||
*/
|
||||
public void eraseThreadLocals() {
|
||||
UNSAFE.putObject(this, THREADLOCALS, null);
|
||||
UNSAFE.putObject(this, INHERITABLETHREADLOCALS, null);
|
||||
}
|
||||
|
||||
// Use Unsafe to access Thread group and ThreadGroup parent fields
|
||||
static {
|
||||
try {
|
||||
@ -95,12 +96,10 @@ public final class InnocuousThread extends Thread {
|
||||
Class<?> tk = Thread.class;
|
||||
Class<?> gk = ThreadGroup.class;
|
||||
|
||||
THREADLOCALS = UNSAFE.objectFieldOffset
|
||||
(tk.getDeclaredField("threadLocals"));
|
||||
INHERITABLETHREADLOCALS = UNSAFE.objectFieldOffset
|
||||
(tk.getDeclaredField("inheritableThreadLocals"));
|
||||
INHERITEDACCESSCONTROLCONTEXT = UNSAFE.objectFieldOffset
|
||||
(tk.getDeclaredField("inheritedAccessControlContext"));
|
||||
CONTEXTCLASSLOADER = UNSAFE.objectFieldOffset
|
||||
(tk.getDeclaredField("contextClassLoader"));
|
||||
|
||||
long tg = UNSAFE.objectFieldOffset(tk.getDeclaredField("group"));
|
||||
long gp = UNSAFE.objectFieldOffset(gk.getDeclaredField("parent"));
|
||||
@ -113,7 +112,10 @@ public final class InnocuousThread extends Thread {
|
||||
break;
|
||||
group = parent;
|
||||
}
|
||||
THREADGROUP = new ThreadGroup(group, "InnocuousThreadGroup");
|
||||
final ThreadGroup root = group;
|
||||
INNOCUOUSTHREADGROUP = AccessController.doPrivileged(
|
||||
(PrivilegedAction<ThreadGroup>) () ->
|
||||
{ return new ThreadGroup(root, "InnocuousThreadGroup"); });
|
||||
} catch (Exception e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
|
@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.misc;
|
||||
|
||||
/**
|
||||
* A thread that has it's thread locals, and inheritable thread
|
||||
* locals erased on construction.
|
||||
*/
|
||||
public class ManagedLocalsThread extends Thread {
|
||||
private static final Unsafe UNSAFE;
|
||||
private static final long THREAD_LOCALS;
|
||||
private static final long INHERITABLE_THREAD_LOCALS;
|
||||
|
||||
public ManagedLocalsThread() {
|
||||
eraseThreadLocals();
|
||||
}
|
||||
|
||||
public ManagedLocalsThread(Runnable target) {
|
||||
super(target);
|
||||
eraseThreadLocals();
|
||||
}
|
||||
|
||||
public ManagedLocalsThread(String name) {
|
||||
super(name);
|
||||
eraseThreadLocals();
|
||||
}
|
||||
|
||||
public ManagedLocalsThread(Runnable target, String name) {
|
||||
super(target, name);
|
||||
eraseThreadLocals();
|
||||
}
|
||||
|
||||
public ManagedLocalsThread(ThreadGroup group, String name) {
|
||||
super(group, name);
|
||||
eraseThreadLocals();
|
||||
}
|
||||
|
||||
public ManagedLocalsThread(ThreadGroup group, Runnable target, String name) {
|
||||
super(group, target, name);
|
||||
eraseThreadLocals();
|
||||
}
|
||||
|
||||
/**
|
||||
* Drops all thread locals (and inherited thread locals).
|
||||
*/
|
||||
public final void eraseThreadLocals() {
|
||||
UNSAFE.putObject(this, THREAD_LOCALS, null);
|
||||
UNSAFE.putObject(this, INHERITABLE_THREAD_LOCALS, null);
|
||||
}
|
||||
|
||||
static {
|
||||
UNSAFE = Unsafe.getUnsafe();
|
||||
Class<?> t = Thread.class;
|
||||
try {
|
||||
THREAD_LOCALS = UNSAFE.objectFieldOffset
|
||||
(t.getDeclaredField("threadLocals"));
|
||||
INHERITABLE_THREAD_LOCALS = UNSAFE.objectFieldOffset
|
||||
(t.getDeclaredField("inheritableThreadLocals"));
|
||||
} catch (Exception e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ public class RequestProcessor implements Runnable {
|
||||
*/
|
||||
public static synchronized void startProcessing() {
|
||||
if (dispatcher == null) {
|
||||
dispatcher = new Thread(new RequestProcessor(), "Request Processor");
|
||||
dispatcher = new ManagedLocalsThread(new RequestProcessor(), "Request Processor");
|
||||
dispatcher.setPriority(Thread.NORM_PRIORITY + 2);
|
||||
dispatcher.start();
|
||||
}
|
||||
|
@ -213,7 +213,7 @@ public final class Signal {
|
||||
}
|
||||
};
|
||||
if (handler != null) {
|
||||
new Thread(runnable, sig + " handler").start();
|
||||
new ManagedLocalsThread(runnable, sig + " handler").start();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,7 @@ package sun.net;
|
||||
import java.io.*;
|
||||
import java.net.Socket;
|
||||
import java.net.ServerSocket;
|
||||
import sun.misc.ManagedLocalsThread;
|
||||
|
||||
/**
|
||||
* This is the base class for network servers. To define a new type
|
||||
@ -72,7 +73,7 @@ public class NetworkServer implements Runnable, Cloneable {
|
||||
NetworkServer n = (NetworkServer)clone();
|
||||
n.serverSocket = null;
|
||||
n.clientSocket = ns;
|
||||
new Thread(n).start();
|
||||
new ManagedLocalsThread(n).start();
|
||||
} catch(Exception e) {
|
||||
System.out.print("Server failure\n");
|
||||
e.printStackTrace();
|
||||
@ -107,7 +108,7 @@ public class NetworkServer implements Runnable, Cloneable {
|
||||
for each new connection. */
|
||||
final public void startServer(int port) throws IOException {
|
||||
serverSocket = new ServerSocket(port, 50);
|
||||
serverInstance = new Thread(this);
|
||||
serverInstance = new ManagedLocalsThread(this);
|
||||
serverInstance.start();
|
||||
}
|
||||
|
||||
|
@ -27,8 +27,9 @@ package sun.net.www;
|
||||
import java.net.URL;
|
||||
import java.io.*;
|
||||
import java.util.StringTokenizer;
|
||||
import sun.misc.ManagedLocalsThread;
|
||||
|
||||
class MimeLauncher extends Thread {
|
||||
class MimeLauncher extends ManagedLocalsThread {
|
||||
java.net.URLConnection uc;
|
||||
MimeEntry m;
|
||||
String genericTempFileTemplate;
|
||||
|
@ -30,6 +30,7 @@ import java.io.NotSerializableException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.net.URL;
|
||||
import sun.misc.InnocuousThread;
|
||||
|
||||
/**
|
||||
* A class that implements a cache of idle Http connections for keep-alive
|
||||
@ -95,15 +96,7 @@ public class KeepAliveCache
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<Void>() {
|
||||
public Void run() {
|
||||
// We want to create the Keep-Alive-Timer in the
|
||||
// system threadgroup
|
||||
ThreadGroup grp = Thread.currentThread().getThreadGroup();
|
||||
ThreadGroup parent = null;
|
||||
while ((parent = grp.getParent()) != null) {
|
||||
grp = parent;
|
||||
}
|
||||
|
||||
keepAliveTimer = new Thread(grp, cache, "Keep-Alive-Timer");
|
||||
keepAliveTimer = new InnocuousThread(cache, "Keep-Alive-Timer");
|
||||
keepAliveTimer.setDaemon(true);
|
||||
keepAliveTimer.setPriority(Thread.MAX_PRIORITY - 2);
|
||||
// Set the context class loader to null in order to avoid
|
||||
|
@ -26,6 +26,8 @@
|
||||
package sun.net.www.http;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
import sun.misc.InnocuousThread;
|
||||
import sun.net.ProgressSource;
|
||||
import sun.net.www.MeteredStream;
|
||||
|
||||
@ -171,15 +173,7 @@ class KeepAliveStream extends MeteredStream implements Hurryable {
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<Void>() {
|
||||
public Void run() {
|
||||
// We want to create the Keep-Alive-SocketCleaner in the
|
||||
// system threadgroup
|
||||
ThreadGroup grp = Thread.currentThread().getThreadGroup();
|
||||
ThreadGroup parent = null;
|
||||
while ((parent = grp.getParent()) != null) {
|
||||
grp = parent;
|
||||
}
|
||||
|
||||
cleanerThread = new Thread(grp, queue, "Keep-Alive-SocketCleaner");
|
||||
cleanerThread = new InnocuousThread(queue, "Keep-Alive-SocketCleaner");
|
||||
cleanerThread.setDaemon(true);
|
||||
cleanerThread.setPriority(Thread.MAX_PRIORITY - 2);
|
||||
// Set the context class loader to null in order to avoid
|
||||
|
@ -30,6 +30,7 @@ import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import sun.misc.ManagedLocalsThread;
|
||||
|
||||
/**
|
||||
* Base implementation of background poller thread used in watch service
|
||||
@ -59,7 +60,7 @@ abstract class AbstractPoller implements Runnable {
|
||||
AccessController.doPrivileged(new PrivilegedAction<Object>() {
|
||||
@Override
|
||||
public Object run() {
|
||||
Thread thr = new Thread(thisRunnable);
|
||||
Thread thr = new ManagedLocalsThread(thisRunnable);
|
||||
thr.setDaemon(true);
|
||||
thr.start();
|
||||
return null;
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
package sun.nio.fs;
|
||||
|
||||
import sun.misc.ManagedLocalsThread;
|
||||
import sun.misc.Unsafe;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
@ -117,7 +118,7 @@ abstract class Cancellable implements Runnable {
|
||||
* thread by writing into the memory location that it polls cooperatively.
|
||||
*/
|
||||
static void runInterruptibly(Cancellable task) throws ExecutionException {
|
||||
Thread t = new Thread(task);
|
||||
Thread t = new ManagedLocalsThread(task);
|
||||
t.start();
|
||||
boolean cancelledByInterrupt = false;
|
||||
while (t.isAlive()) {
|
||||
|
@ -35,6 +35,7 @@ import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import com.sun.nio.file.SensitivityWatchEventModifier;
|
||||
import sun.misc.ManagedLocalsThread;
|
||||
|
||||
/**
|
||||
* Simple WatchService implementation that uses periodic tasks to poll
|
||||
@ -58,7 +59,7 @@ class PollingWatchService
|
||||
.newSingleThreadScheduledExecutor(new ThreadFactory() {
|
||||
@Override
|
||||
public Thread newThread(Runnable r) {
|
||||
Thread t = new Thread(r);
|
||||
Thread t = new ManagedLocalsThread(r);
|
||||
t.setDaemon(true);
|
||||
return t;
|
||||
}});
|
||||
|
@ -716,6 +716,11 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
|
||||
|
||||
entry.protectedPrivKey = key.clone();
|
||||
if (chain != null) {
|
||||
// validate cert-chain
|
||||
if ((chain.length > 1) && (!validateChain(chain))) {
|
||||
throw new KeyStoreException("Certificate chain is "
|
||||
+ "not valid");
|
||||
}
|
||||
entry.chain = chain.clone();
|
||||
certificateCount += chain.length;
|
||||
|
||||
@ -1490,7 +1495,12 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
|
||||
if (!(issuerDN.equals(subjectDN)))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
// Check for loops in the chain. If there are repeated certs,
|
||||
// the Set of certs in the chain will contain fewer certs than
|
||||
// the chain
|
||||
Set<Certificate> set = new HashSet<>(Arrays.asList(certChain));
|
||||
return set.size() == certChain.length;
|
||||
}
|
||||
|
||||
|
||||
@ -2070,7 +2080,24 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
|
||||
ArrayList<X509Certificate> chain =
|
||||
new ArrayList<X509Certificate>();
|
||||
X509Certificate cert = findMatchedCertificate(entry);
|
||||
|
||||
mainloop:
|
||||
while (cert != null) {
|
||||
// Check for loops in the certificate chain
|
||||
if (!chain.isEmpty()) {
|
||||
for (X509Certificate chainCert : chain) {
|
||||
if (cert.equals(chainCert)) {
|
||||
if (debug != null) {
|
||||
debug.println("Loop detected in " +
|
||||
"certificate chain. Skip adding " +
|
||||
"repeated cert to chain. Subject: " +
|
||||
cert.getSubjectX500Principal()
|
||||
.toString());
|
||||
}
|
||||
break mainloop;
|
||||
}
|
||||
}
|
||||
}
|
||||
chain.add(cert);
|
||||
X500Principal issuerDN = cert.getIssuerX500Principal();
|
||||
if (issuerDN.equals(cert.getSubjectX500Principal())) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -75,6 +75,7 @@ import java.nio.file.DirectoryStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Random;
|
||||
import sun.misc.ManagedLocalsThread;
|
||||
import sun.security.util.Debug;
|
||||
|
||||
abstract class SeedGenerator {
|
||||
@ -304,7 +305,7 @@ abstract class SeedGenerator {
|
||||
}
|
||||
finalsg[0] = new ThreadGroup
|
||||
(group, "SeedGenerator ThreadGroup");
|
||||
Thread newT = new Thread(finalsg[0],
|
||||
Thread newT = new ManagedLocalsThread(finalsg[0],
|
||||
ThreadedSeedGenerator.this,
|
||||
"SeedGenerator Thread");
|
||||
newT.setPriority(Thread.MIN_PRIORITY);
|
||||
@ -341,7 +342,7 @@ abstract class SeedGenerator {
|
||||
// Start some noisy threads
|
||||
try {
|
||||
BogusThread bt = new BogusThread();
|
||||
Thread t = new Thread
|
||||
Thread t = new ManagedLocalsThread
|
||||
(seedGroup, bt, "SeedGenerator Thread");
|
||||
t.start();
|
||||
} catch (Exception e) {
|
||||
|
@ -551,10 +551,10 @@ public class DistributionPointFetcher {
|
||||
// set interim reasons mask to the intersection of
|
||||
// reasons in the DP and onlySomeReasons in the IDP
|
||||
boolean[] idpReasonFlags = reasons.getFlags();
|
||||
for (int i = 0; i < idpReasonFlags.length; i++) {
|
||||
if (idpReasonFlags[i] && pointReasonFlags[i]) {
|
||||
interimReasonsMask[i] = true;
|
||||
}
|
||||
for (int i = 0; i < interimReasonsMask.length; i++) {
|
||||
interimReasonsMask[i] =
|
||||
(i < idpReasonFlags.length && idpReasonFlags[i]) &&
|
||||
(i < pointReasonFlags.length && pointReasonFlags[i]);
|
||||
}
|
||||
} else {
|
||||
// set interim reasons mask to the value of
|
||||
@ -568,7 +568,6 @@ public class DistributionPointFetcher {
|
||||
interimReasonsMask = pointReasonFlags.clone();
|
||||
} else {
|
||||
// set interim reasons mask to the special value all-reasons
|
||||
interimReasonsMask = new boolean[9];
|
||||
Arrays.fill(interimReasonsMask, true);
|
||||
}
|
||||
}
|
||||
@ -577,7 +576,9 @@ public class DistributionPointFetcher {
|
||||
// not included in the reasons mask
|
||||
boolean oneOrMore = false;
|
||||
for (int i = 0; i < interimReasonsMask.length && !oneOrMore; i++) {
|
||||
if (!reasonsMask[i] && interimReasonsMask[i]) {
|
||||
if (interimReasonsMask[i] &&
|
||||
!(i < reasonsMask.length && reasonsMask[i]))
|
||||
{
|
||||
oneOrMore = true;
|
||||
}
|
||||
}
|
||||
@ -703,11 +704,11 @@ public class DistributionPointFetcher {
|
||||
}
|
||||
|
||||
// update reasonsMask
|
||||
for (int i = 0; i < interimReasonsMask.length; i++) {
|
||||
if (!reasonsMask[i] && interimReasonsMask[i]) {
|
||||
reasonsMask[i] = true;
|
||||
}
|
||||
for (int i = 0; i < reasonsMask.length; i++) {
|
||||
reasonsMask[i] = reasonsMask[i] ||
|
||||
(i < interimReasonsMask.length && interimReasonsMask[i]);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -102,12 +102,24 @@ public final class RSACore {
|
||||
|
||||
/**
|
||||
* Perform an RSA private key operation. Uses CRT if the key is a
|
||||
* CRT key.
|
||||
* CRT key with additional verification check after the signature
|
||||
* is computed.
|
||||
*/
|
||||
@Deprecated
|
||||
public static byte[] rsa(byte[] msg, RSAPrivateKey key)
|
||||
throws BadPaddingException {
|
||||
return rsa(msg, key, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform an RSA private key operation. Uses CRT if the key is a
|
||||
* CRT key. Set 'verify' to true if this function is used for
|
||||
* generating a signature.
|
||||
*/
|
||||
public static byte[] rsa(byte[] msg, RSAPrivateKey key, boolean verify)
|
||||
throws BadPaddingException {
|
||||
if (key instanceof RSAPrivateCrtKey) {
|
||||
return crtCrypt(msg, (RSAPrivateCrtKey)key);
|
||||
return crtCrypt(msg, (RSAPrivateCrtKey)key, verify);
|
||||
} else {
|
||||
return priCrypt(msg, key.getModulus(), key.getPrivateExponent());
|
||||
}
|
||||
@ -148,10 +160,11 @@ public final class RSACore {
|
||||
* RSA private key operations with CRT. Algorithm and variable naming
|
||||
* are taken from PKCS#1 v2.1, section 5.1.2.
|
||||
*/
|
||||
private static byte[] crtCrypt(byte[] msg, RSAPrivateCrtKey key)
|
||||
throws BadPaddingException {
|
||||
private static byte[] crtCrypt(byte[] msg, RSAPrivateCrtKey key,
|
||||
boolean verify) throws BadPaddingException {
|
||||
BigInteger n = key.getModulus();
|
||||
BigInteger c = parseMsg(msg, n);
|
||||
BigInteger c0 = parseMsg(msg, n);
|
||||
BigInteger c = c0;
|
||||
BigInteger p = key.getPrimeP();
|
||||
BigInteger q = key.getPrimeQ();
|
||||
BigInteger dP = key.getPrimeExponentP();
|
||||
@ -184,6 +197,9 @@ public final class RSACore {
|
||||
if (ENABLE_BLINDING) {
|
||||
m = m.multiply(brp.v).mod(n);
|
||||
}
|
||||
if (verify && !c0.equals(m.modPow(e, n))) {
|
||||
throw new BadPaddingException("RSA private key operation failed");
|
||||
}
|
||||
|
||||
return toByteArray(m, getByteLength(n));
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -173,7 +173,7 @@ public abstract class RSASignature extends SignatureSpi {
|
||||
try {
|
||||
byte[] encoded = encodeSignature(digestOID, digest);
|
||||
byte[] padded = padding.pad(encoded);
|
||||
byte[] encrypted = RSACore.rsa(padded, privateKey);
|
||||
byte[] encrypted = RSACore.rsa(padded, privateKey, true);
|
||||
return encrypted;
|
||||
} catch (GeneralSecurityException e) {
|
||||
throw new SignatureException("Could not sign data", e);
|
||||
|
@ -293,7 +293,7 @@ final class ClientHandshaker extends Handshaker {
|
||||
case K_ECDH_RSA:
|
||||
throw new SSLProtocolException(
|
||||
"Protocol violation: server sent a server key exchange"
|
||||
+ "message for key exchange " + keyExchange);
|
||||
+ " message for key exchange " + keyExchange);
|
||||
case K_KRB5:
|
||||
case K_KRB5_EXPORT:
|
||||
throw new SSLProtocolException(
|
||||
|
@ -39,6 +39,7 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import javax.crypto.BadPaddingException;
|
||||
import javax.net.ssl.*;
|
||||
import sun.misc.ManagedLocalsThread;
|
||||
|
||||
/**
|
||||
* Implementation of an SSL socket. This is a normal connection type
|
||||
@ -1078,8 +1079,10 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
|
||||
HandshakeCompletedEvent event =
|
||||
new HandshakeCompletedEvent(this, sess);
|
||||
|
||||
Thread t = new NotifyHandshakeThread(
|
||||
handshakeListeners.entrySet(), event);
|
||||
Thread t = new ManagedLocalsThread(
|
||||
new NotifyHandshake(
|
||||
handshakeListeners.entrySet(), event),
|
||||
"HandshakeCompletedNotify-Thread");
|
||||
t.start();
|
||||
}
|
||||
}
|
||||
@ -2575,17 +2578,16 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
|
||||
// events. This ensures that the notifications don't block the
|
||||
// protocol state machine.
|
||||
//
|
||||
private static class NotifyHandshakeThread extends Thread {
|
||||
private static class NotifyHandshake implements Runnable {
|
||||
|
||||
private Set<Map.Entry<HandshakeCompletedListener,AccessControlContext>>
|
||||
targets; // who gets notified
|
||||
private HandshakeCompletedEvent event; // the notification
|
||||
|
||||
NotifyHandshakeThread(
|
||||
NotifyHandshake(
|
||||
Set<Map.Entry<HandshakeCompletedListener,AccessControlContext>>
|
||||
entrySet, HandshakeCompletedEvent e) {
|
||||
|
||||
super("HandshakeCompletedNotify-Thread");
|
||||
targets = new HashSet<>(entrySet); // clone the entry set
|
||||
event = e;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -132,26 +132,33 @@ class EndEntityChecker {
|
||||
return new EndEntityChecker(type, variant);
|
||||
}
|
||||
|
||||
void check(X509Certificate cert, Object parameter)
|
||||
throws CertificateException {
|
||||
void check(X509Certificate cert, Object parameter,
|
||||
boolean checkUnresolvedCritExts) throws CertificateException {
|
||||
if (variant.equals(Validator.VAR_GENERIC)) {
|
||||
// no checks
|
||||
return;
|
||||
} else if (variant.equals(Validator.VAR_TLS_SERVER)) {
|
||||
checkTLSServer(cert, (String)parameter);
|
||||
return; // no checks
|
||||
}
|
||||
|
||||
Set<String> exts = getCriticalExtensions(cert);
|
||||
if (variant.equals(Validator.VAR_TLS_SERVER)) {
|
||||
checkTLSServer(cert, (String)parameter, exts);
|
||||
} else if (variant.equals(Validator.VAR_TLS_CLIENT)) {
|
||||
checkTLSClient(cert);
|
||||
checkTLSClient(cert, exts);
|
||||
} else if (variant.equals(Validator.VAR_CODE_SIGNING)) {
|
||||
checkCodeSigning(cert);
|
||||
checkCodeSigning(cert, exts);
|
||||
} else if (variant.equals(Validator.VAR_JCE_SIGNING)) {
|
||||
checkCodeSigning(cert);
|
||||
checkCodeSigning(cert, exts);
|
||||
} else if (variant.equals(Validator.VAR_PLUGIN_CODE_SIGNING)) {
|
||||
checkCodeSigning(cert);
|
||||
checkCodeSigning(cert, exts);
|
||||
} else if (variant.equals(Validator.VAR_TSA_SERVER)) {
|
||||
checkTSAServer(cert);
|
||||
checkTSAServer(cert, exts);
|
||||
} else {
|
||||
throw new CertificateException("Unknown variant: " + variant);
|
||||
}
|
||||
|
||||
// if neither VAR_GENERIC variant nor unknown variant
|
||||
if (checkUnresolvedCritExts) {
|
||||
checkRemainingExtensions(exts);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -219,10 +226,8 @@ class EndEntityChecker {
|
||||
* authentication.
|
||||
* @throws CertificateException if not.
|
||||
*/
|
||||
private void checkTLSClient(X509Certificate cert)
|
||||
private void checkTLSClient(X509Certificate cert, Set<String> exts)
|
||||
throws CertificateException {
|
||||
Set<String> exts = getCriticalExtensions(cert);
|
||||
|
||||
if (checkKeyUsage(cert, KU_SIGNATURE) == false) {
|
||||
throw new ValidatorException
|
||||
("KeyUsage does not allow digital signatures",
|
||||
@ -245,8 +250,6 @@ class EndEntityChecker {
|
||||
exts.remove(SimpleValidator.OID_KEY_USAGE);
|
||||
exts.remove(SimpleValidator.OID_EXTENDED_KEY_USAGE);
|
||||
exts.remove(SimpleValidator.OID_NETSCAPE_CERT_TYPE);
|
||||
|
||||
checkRemainingExtensions(exts);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -255,10 +258,8 @@ class EndEntityChecker {
|
||||
* specification for details.
|
||||
* @throws CertificateException if not.
|
||||
*/
|
||||
private void checkTLSServer(X509Certificate cert, String parameter)
|
||||
throws CertificateException {
|
||||
Set<String> exts = getCriticalExtensions(cert);
|
||||
|
||||
private void checkTLSServer(X509Certificate cert, String parameter,
|
||||
Set<String> exts) throws CertificateException {
|
||||
if (KU_SERVER_ENCRYPTION.contains(parameter)) {
|
||||
if (checkKeyUsage(cert, KU_KEY_ENCIPHERMENT) == false) {
|
||||
throw new ValidatorException
|
||||
@ -303,18 +304,14 @@ class EndEntityChecker {
|
||||
exts.remove(SimpleValidator.OID_KEY_USAGE);
|
||||
exts.remove(SimpleValidator.OID_EXTENDED_KEY_USAGE);
|
||||
exts.remove(SimpleValidator.OID_NETSCAPE_CERT_TYPE);
|
||||
|
||||
checkRemainingExtensions(exts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether this certificate can be used for code signing.
|
||||
* @throws CertificateException if not.
|
||||
*/
|
||||
private void checkCodeSigning(X509Certificate cert)
|
||||
private void checkCodeSigning(X509Certificate cert, Set<String> exts)
|
||||
throws CertificateException {
|
||||
Set<String> exts = getCriticalExtensions(cert);
|
||||
|
||||
if (checkKeyUsage(cert, KU_SIGNATURE) == false) {
|
||||
throw new ValidatorException
|
||||
("KeyUsage does not allow digital signatures",
|
||||
@ -341,8 +338,6 @@ class EndEntityChecker {
|
||||
// remove extensions we checked
|
||||
exts.remove(SimpleValidator.OID_KEY_USAGE);
|
||||
exts.remove(SimpleValidator.OID_EXTENDED_KEY_USAGE);
|
||||
|
||||
checkRemainingExtensions(exts);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -350,10 +345,8 @@ class EndEntityChecker {
|
||||
* server (see RFC 3161, section 2.3).
|
||||
* @throws CertificateException if not.
|
||||
*/
|
||||
private void checkTSAServer(X509Certificate cert)
|
||||
private void checkTSAServer(X509Certificate cert, Set<String> exts)
|
||||
throws CertificateException {
|
||||
Set<String> exts = getCriticalExtensions(cert);
|
||||
|
||||
if (checkKeyUsage(cert, KU_SIGNATURE) == false) {
|
||||
throw new ValidatorException
|
||||
("KeyUsage does not allow digital signatures",
|
||||
@ -376,7 +369,5 @@ class EndEntityChecker {
|
||||
// remove extensions we checked
|
||||
exts.remove(SimpleValidator.OID_KEY_USAGE);
|
||||
exts.remove(SimpleValidator.OID_EXTENDED_KEY_USAGE);
|
||||
|
||||
checkRemainingExtensions(exts);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -143,6 +143,7 @@ public abstract class Validator {
|
||||
*/
|
||||
public final static String VAR_PLUGIN_CODE_SIGNING = "plugin code signing";
|
||||
|
||||
private final String type;
|
||||
final EndEntityChecker endEntityChecker;
|
||||
final String variant;
|
||||
|
||||
@ -154,6 +155,7 @@ public abstract class Validator {
|
||||
volatile Date validationDate;
|
||||
|
||||
Validator(String type, String variant) {
|
||||
this.type = type;
|
||||
this.variant = variant;
|
||||
endEntityChecker = EndEntityChecker.getInstance(type, variant);
|
||||
}
|
||||
@ -261,7 +263,16 @@ public abstract class Validator {
|
||||
|
||||
// omit EE extension check if EE cert is also trust anchor
|
||||
if (chain.length > 1) {
|
||||
endEntityChecker.check(chain[0], parameter);
|
||||
// EndEntityChecker does not need to check unresolved critical
|
||||
// extensions when validating with a TYPE_PKIX Validator.
|
||||
// A TYPE_PKIX Validator will already have run checks on all
|
||||
// certs' extensions, including checks by any PKIXCertPathCheckers
|
||||
// included in the PKIXParameters, so the extra checks would be
|
||||
// redundant.
|
||||
boolean checkUnresolvedCritExts =
|
||||
(type == TYPE_PKIX) ? false : true;
|
||||
endEntityChecker.check(chain[0], parameter,
|
||||
checkUnresolvedCritExts);
|
||||
}
|
||||
|
||||
return chain;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -83,7 +83,8 @@ implements CertAttrSet<String> {
|
||||
* @param position the position in the bit string to check.
|
||||
*/
|
||||
private boolean isSet(int position) {
|
||||
return bitString[position];
|
||||
return (position < bitString.length) &&
|
||||
bitString[position];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -275,41 +276,40 @@ implements CertAttrSet<String> {
|
||||
* Returns a printable representation of the KeyUsage.
|
||||
*/
|
||||
public String toString() {
|
||||
String s = super.toString() + "KeyUsage [\n";
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(super.toString());
|
||||
sb.append("KeyUsage [\n");
|
||||
|
||||
try {
|
||||
if (isSet(0)) {
|
||||
s += " DigitalSignature\n";
|
||||
}
|
||||
if (isSet(1)) {
|
||||
s += " Non_repudiation\n";
|
||||
}
|
||||
if (isSet(2)) {
|
||||
s += " Key_Encipherment\n";
|
||||
}
|
||||
if (isSet(3)) {
|
||||
s += " Data_Encipherment\n";
|
||||
}
|
||||
if (isSet(4)) {
|
||||
s += " Key_Agreement\n";
|
||||
}
|
||||
if (isSet(5)) {
|
||||
s += " Key_CertSign\n";
|
||||
}
|
||||
if (isSet(6)) {
|
||||
s += " Crl_Sign\n";
|
||||
}
|
||||
if (isSet(7)) {
|
||||
s += " Encipher_Only\n";
|
||||
}
|
||||
if (isSet(8)) {
|
||||
s += " Decipher_Only\n";
|
||||
}
|
||||
} catch (ArrayIndexOutOfBoundsException ex) {}
|
||||
if (isSet(0)) {
|
||||
sb.append(" DigitalSignature\n");
|
||||
}
|
||||
if (isSet(1)) {
|
||||
sb.append(" Non_repudiation\n");
|
||||
}
|
||||
if (isSet(2)) {
|
||||
sb.append(" Key_Encipherment\n");
|
||||
}
|
||||
if (isSet(3)) {
|
||||
sb.append(" Data_Encipherment\n");
|
||||
}
|
||||
if (isSet(4)) {
|
||||
sb.append(" Key_Agreement\n");
|
||||
}
|
||||
if (isSet(5)) {
|
||||
sb.append(" Key_CertSign\n");
|
||||
}
|
||||
if (isSet(6)) {
|
||||
sb.append(" Crl_Sign\n");
|
||||
}
|
||||
if (isSet(7)) {
|
||||
sb.append(" Encipher_Only\n");
|
||||
}
|
||||
if (isSet(8)) {
|
||||
sb.append(" Decipher_Only\n");
|
||||
}
|
||||
sb.append("]\n");
|
||||
|
||||
s += "]\n";
|
||||
|
||||
return (s);
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -136,7 +136,8 @@ implements CertAttrSet<String> {
|
||||
* @param position the position in the bit string to check.
|
||||
*/
|
||||
private boolean isSet(int position) {
|
||||
return bitString[position];
|
||||
return (position < bitString.length) &&
|
||||
bitString[position];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -236,27 +237,34 @@ implements CertAttrSet<String> {
|
||||
* Returns a printable representation of the NetscapeCertType.
|
||||
*/
|
||||
public String toString() {
|
||||
String s = super.toString() + "NetscapeCertType [\n";
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(super.toString());
|
||||
sb.append("NetscapeCertType [\n");
|
||||
|
||||
try {
|
||||
if (isSet(getPosition(SSL_CLIENT)))
|
||||
s += " SSL client\n";
|
||||
if (isSet(getPosition(SSL_SERVER)))
|
||||
s += " SSL server\n";
|
||||
if (isSet(getPosition(S_MIME)))
|
||||
s += " S/MIME\n";
|
||||
if (isSet(getPosition(OBJECT_SIGNING)))
|
||||
s += " Object Signing\n";
|
||||
if (isSet(getPosition(SSL_CA)))
|
||||
s += " SSL CA\n";
|
||||
if (isSet(getPosition(S_MIME_CA)))
|
||||
s += " S/MIME CA\n";
|
||||
if (isSet(getPosition(OBJECT_SIGNING_CA)))
|
||||
s += " Object Signing CA" ;
|
||||
} catch (Exception e) { }
|
||||
if (isSet(0)) {
|
||||
sb.append(" SSL client\n");
|
||||
}
|
||||
if (isSet(1)) {
|
||||
sb.append(" SSL server\n");
|
||||
}
|
||||
if (isSet(2)) {
|
||||
sb.append(" S/MIME\n");
|
||||
}
|
||||
if (isSet(3)) {
|
||||
sb.append(" Object Signing\n");
|
||||
}
|
||||
if (isSet(5)) {
|
||||
sb.append(" SSL CA\n");
|
||||
}
|
||||
if (isSet(6)) {
|
||||
sb.append(" S/MIME CA\n");
|
||||
}
|
||||
if (isSet(7)) {
|
||||
sb.append(" Object Signing CA");
|
||||
}
|
||||
|
||||
s += "]\n";
|
||||
return (s);
|
||||
sb.append("]\n");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -99,7 +99,8 @@ public class ReasonFlags {
|
||||
* @param position the position in the bit string to check.
|
||||
*/
|
||||
private boolean isSet(int position) {
|
||||
return bitString[position];
|
||||
return (position < bitString.length) &&
|
||||
bitString[position];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -199,23 +200,38 @@ public class ReasonFlags {
|
||||
* Returns a printable representation of the ReasonFlags.
|
||||
*/
|
||||
public String toString() {
|
||||
String s = "Reason Flags [\n";
|
||||
StringBuilder sb = new StringBuilder("Reason Flags [\n");
|
||||
|
||||
try {
|
||||
if (isSet(0)) s += " Unused\n";
|
||||
if (isSet(1)) s += " Key Compromise\n";
|
||||
if (isSet(2)) s += " CA Compromise\n";
|
||||
if (isSet(3)) s += " Affiliation_Changed\n";
|
||||
if (isSet(4)) s += " Superseded\n";
|
||||
if (isSet(5)) s += " Cessation Of Operation\n";
|
||||
if (isSet(6)) s += " Certificate Hold\n";
|
||||
if (isSet(7)) s += " Privilege Withdrawn\n";
|
||||
if (isSet(8)) s += " AA Compromise\n";
|
||||
} catch (ArrayIndexOutOfBoundsException ex) {}
|
||||
if (isSet(0)) {
|
||||
sb.append(" Unused\n");
|
||||
}
|
||||
if (isSet(1)) {
|
||||
sb.append(" Key Compromise\n");
|
||||
}
|
||||
if (isSet(2)) {
|
||||
sb.append(" CA Compromise\n");
|
||||
}
|
||||
if (isSet(3)) {
|
||||
sb.append(" Affiliation_Changed\n");
|
||||
}
|
||||
if (isSet(4)) {
|
||||
sb.append(" Superseded\n");
|
||||
}
|
||||
if (isSet(5)) {
|
||||
sb.append(" Cessation Of Operation\n");
|
||||
}
|
||||
if (isSet(6)) {
|
||||
sb.append(" Certificate Hold\n");
|
||||
}
|
||||
if (isSet(7)) {
|
||||
sb.append(" Privilege Withdrawn\n");
|
||||
}
|
||||
if (isSet(8)) {
|
||||
sb.append(" AA Compromise\n");
|
||||
}
|
||||
sb.append("]\n");
|
||||
|
||||
s += "]\n";
|
||||
|
||||
return (s);
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -533,4 +533,4 @@ jdk.certpath.disabledAlgorithms=MD2, MD5, RSA keySize < 1024
|
||||
#
|
||||
# Example:
|
||||
# jdk.tls.disabledAlgorithms=MD5, SSLv3, DSA, RSA keySize < 2048
|
||||
jdk.tls.disabledAlgorithms=SSLv3
|
||||
jdk.tls.disabledAlgorithms=SSLv3, RC4
|
||||
|
@ -40,6 +40,7 @@ import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import sun.misc.ManagedLocalsThread;
|
||||
|
||||
/**
|
||||
* A multi-threaded implementation of Selector for Windows.
|
||||
@ -403,7 +404,7 @@ final class WindowsSelectorImpl extends SelectorImpl {
|
||||
}
|
||||
|
||||
// Represents a helper thread used for select.
|
||||
private final class SelectThread extends Thread {
|
||||
private final class SelectThread extends ManagedLocalsThread {
|
||||
private final int index; // index of this thread
|
||||
final SubSelector subSelector;
|
||||
private long lastRun = 0; // last run number
|
||||
|
@ -25,15 +25,16 @@
|
||||
|
||||
package com.apple.laf;
|
||||
|
||||
|
||||
import java.beans.*;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ListDataEvent;
|
||||
import javax.swing.filechooser.FileSystemView;
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
|
||||
import sun.misc.ManagedLocalsThread;
|
||||
/**
|
||||
* NavServices-like implementation of a file Table
|
||||
*
|
||||
@ -42,7 +43,7 @@ import javax.swing.table.AbstractTableModel;
|
||||
@SuppressWarnings("serial") // Superclass is not serializable across versions
|
||||
class AquaFileSystemModel extends AbstractTableModel implements PropertyChangeListener {
|
||||
private final JTable fFileList;
|
||||
private LoadFilesThread loadThread = null;
|
||||
private FilesLoader filesLoader = null;
|
||||
private Vector<File> files = null;
|
||||
|
||||
JFileChooser filechooser = null;
|
||||
@ -141,9 +142,9 @@ class AquaFileSystemModel extends AbstractTableModel implements PropertyChangeLi
|
||||
|
||||
public void runWhenDone(final Runnable runnable){
|
||||
synchronized (fileCacheLock) {
|
||||
if (loadThread != null) {
|
||||
if (loadThread.isAlive()) {
|
||||
loadThread.queuedTasks.add(runnable);
|
||||
if (filesLoader != null) {
|
||||
if (filesLoader.loadThread.isAlive()) {
|
||||
filesLoader.queuedTasks.add(runnable);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -160,9 +161,9 @@ class AquaFileSystemModel extends AbstractTableModel implements PropertyChangeLi
|
||||
return;
|
||||
}
|
||||
|
||||
if (loadThread != null) {
|
||||
if (filesLoader != null) {
|
||||
// interrupt
|
||||
loadThread.interrupt();
|
||||
filesLoader.loadThread.interrupt();
|
||||
}
|
||||
|
||||
fetchID++;
|
||||
@ -173,8 +174,7 @@ class AquaFileSystemModel extends AbstractTableModel implements PropertyChangeLi
|
||||
fileCache = new Vector<SortableFile>(50);
|
||||
}
|
||||
|
||||
loadThread = new LoadFilesThread(currentDirectory, fetchID);
|
||||
loadThread.start();
|
||||
filesLoader = new FilesLoader(currentDirectory, fetchID);
|
||||
}
|
||||
|
||||
public int getColumnCount() {
|
||||
@ -373,17 +373,25 @@ class AquaFileSystemModel extends AbstractTableModel implements PropertyChangeLi
|
||||
}
|
||||
}
|
||||
|
||||
class LoadFilesThread extends Thread {
|
||||
Vector<Runnable> queuedTasks = new Vector<Runnable>();
|
||||
class FilesLoader implements Runnable {
|
||||
Vector<Runnable> queuedTasks = new Vector<>();
|
||||
File currentDirectory = null;
|
||||
int fid;
|
||||
Thread loadThread;
|
||||
|
||||
public LoadFilesThread(final File currentDirectory, final int fid) {
|
||||
super("Aqua L&F File Loading Thread");
|
||||
public FilesLoader(final File currentDirectory, final int fid) {
|
||||
this.currentDirectory = currentDirectory;
|
||||
this.fid = fid;
|
||||
String name = "Aqua L&F File Loading Thread";
|
||||
if (System.getSecurityManager() == null) {
|
||||
this.loadThread = new Thread(FilesLoader.this, name);
|
||||
} else {
|
||||
this.loadThread = new ManagedLocalsThread(FilesLoader.this, name);
|
||||
}
|
||||
this.loadThread.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
final Vector<DoChangeContents> runnables = new Vector<DoChangeContents>(10);
|
||||
final FileSystemView fileSystem = filechooser.getFileSystemView();
|
||||
@ -415,7 +423,7 @@ class AquaFileSystemModel extends AbstractTableModel implements PropertyChangeLi
|
||||
runnables.addElement(runnable);
|
||||
SwingUtilities.invokeLater(runnable);
|
||||
chunk = new Vector<SortableFile>(10);
|
||||
if (isInterrupted()) {
|
||||
if (loadThread.isInterrupted()) {
|
||||
// interrupted, cancel all runnables
|
||||
cancelRunnables(runnables);
|
||||
return;
|
||||
|
@ -42,6 +42,7 @@ import sun.awt.FontConfiguration;
|
||||
import sun.awt.HeadlessToolkit;
|
||||
import sun.awt.util.ThreadGroupUtils;
|
||||
import sun.lwawt.macosx.*;
|
||||
import sun.misc.InnocuousThread;
|
||||
|
||||
public final class CFontManager extends SunFontManager {
|
||||
private static Hashtable<String, Font2D> genericFonts = new Hashtable<String, Font2D>();
|
||||
@ -211,14 +212,18 @@ public final class CFontManager extends SunFontManager {
|
||||
});
|
||||
}
|
||||
};
|
||||
AccessController.doPrivileged(
|
||||
(PrivilegedAction<Void>) () -> {
|
||||
/* The thread must be a member of a thread group
|
||||
* which will not get GCed before VM exit.
|
||||
* Make its parent the top-level thread group.
|
||||
*/
|
||||
ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
|
||||
fileCloser = new Thread(rootTG, fileCloserRunnable);
|
||||
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
|
||||
if (System.getSecurityManager() == null) {
|
||||
/* The thread must be a member of a thread group
|
||||
* which will not get GCed before VM exit.
|
||||
* Make its parent the top-level thread group.
|
||||
*/
|
||||
ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
|
||||
fileCloser = new Thread(rootTG, fileCloserRunnable);
|
||||
} else {
|
||||
/* InnocuousThread is a member of a correct TG by default */
|
||||
fileCloser = new InnocuousThread(fileCloserRunnable);
|
||||
}
|
||||
fileCloser.setContextClassLoader(null);
|
||||
Runtime.getRuntime().addShutdownHook(fileCloser);
|
||||
return null;
|
||||
|
@ -35,6 +35,7 @@ import java.security.*;
|
||||
import java.util.*;
|
||||
|
||||
import sun.awt.*;
|
||||
import sun.misc.InnocuousThread;
|
||||
import sun.print.*;
|
||||
import sun.awt.util.ThreadGroupUtils;
|
||||
|
||||
@ -71,22 +72,32 @@ public abstract class LWToolkit extends SunToolkit implements Runnable {
|
||||
*/
|
||||
protected final void init() {
|
||||
AWTAutoShutdown.notifyToolkitThreadBusy();
|
||||
|
||||
ThreadGroup rootTG = AccessController.doPrivileged(
|
||||
(PrivilegedAction<ThreadGroup>) ThreadGroupUtils::getRootThreadGroup);
|
||||
|
||||
Runtime.getRuntime().addShutdownHook(
|
||||
new Thread(rootTG, () -> {
|
||||
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
|
||||
Runnable shutdownRunnable = () -> {
|
||||
shutdown();
|
||||
waitForRunState(STATE_CLEANUP);
|
||||
})
|
||||
);
|
||||
|
||||
Thread toolkitThread = new Thread(rootTG, this, "AWT-LW");
|
||||
toolkitThread.setDaemon(true);
|
||||
toolkitThread.setPriority(Thread.NORM_PRIORITY + 1);
|
||||
toolkitThread.start();
|
||||
};
|
||||
Thread shutdown;
|
||||
if (System.getSecurityManager() == null) {
|
||||
shutdown = new Thread(ThreadGroupUtils.getRootThreadGroup(), shutdownRunnable);
|
||||
} else {
|
||||
shutdown = new InnocuousThread(shutdownRunnable);
|
||||
}
|
||||
shutdown.setContextClassLoader(null);
|
||||
Runtime.getRuntime().addShutdownHook(shutdown);
|
||||
|
||||
String name = "AWT-LW";
|
||||
Thread toolkitThread;
|
||||
if (System.getSecurityManager() == null) {
|
||||
toolkitThread = new Thread(ThreadGroupUtils.getRootThreadGroup(), LWToolkit.this, name);
|
||||
} else {
|
||||
toolkitThread = new InnocuousThread(LWToolkit.this, name);
|
||||
}
|
||||
toolkitThread.setDaemon(true);
|
||||
toolkitThread.setPriority(Thread.NORM_PRIORITY + 1);
|
||||
toolkitThread.start();
|
||||
return null;
|
||||
});
|
||||
waitForRunState(STATE_MESSAGELOOP);
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,6 @@ import java.awt.datatransfer.*;
|
||||
import java.awt.dnd.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.image.*;
|
||||
import java.awt.peer.*;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.text.*;
|
||||
@ -44,6 +43,7 @@ import sun.awt.dnd.*;
|
||||
import sun.lwawt.LWComponentPeer;
|
||||
import sun.lwawt.LWWindowPeer;
|
||||
import sun.lwawt.PlatformWindow;
|
||||
import sun.misc.ManagedLocalsThread;
|
||||
|
||||
|
||||
public final class CDragSourceContextPeer extends SunDragSourceContextPeer {
|
||||
@ -164,28 +164,29 @@ public final class CDragSourceContextPeer extends SunDragSourceContextPeer {
|
||||
// are posted during dragging by native event handlers.
|
||||
|
||||
try {
|
||||
Thread dragThread = new Thread() {
|
||||
public void run() {
|
||||
final long nativeDragSource = getNativeContext();
|
||||
try {
|
||||
doDragging(nativeDragSource);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
releaseNativeDragSource(nativeDragSource);
|
||||
fDragImage = null;
|
||||
if (fDragCImage != null) {
|
||||
fDragCImage.dispose();
|
||||
fDragCImage = null;
|
||||
}
|
||||
Runnable dragRunnable = () -> {
|
||||
final long nativeDragSource = getNativeContext();
|
||||
try {
|
||||
doDragging(nativeDragSource);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
releaseNativeDragSource(nativeDragSource);
|
||||
fDragImage = null;
|
||||
if (fDragCImage != null) {
|
||||
fDragCImage.dispose();
|
||||
fDragCImage = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Thread dragThread;
|
||||
if (System.getSecurityManager() == null) {
|
||||
dragThread = new Thread(dragRunnable);
|
||||
} else {
|
||||
dragThread = new ManagedLocalsThread(dragRunnable);
|
||||
}
|
||||
dragThread.start();
|
||||
}
|
||||
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
final long nativeDragSource = getNativeContext();
|
||||
setNativeContext(0);
|
||||
releaseNativeDragSource(nativeDragSource);
|
||||
|
@ -37,6 +37,7 @@ import java.io.*;
|
||||
import sun.awt.CausedFocusEvent.Cause;
|
||||
import sun.awt.AWTAccessor;
|
||||
import sun.java2d.pipe.Region;
|
||||
import sun.misc.ManagedLocalsThread;
|
||||
import sun.security.action.GetBooleanAction;
|
||||
|
||||
class CFileDialog implements FileDialogPeer {
|
||||
@ -119,7 +120,11 @@ class CFileDialog implements FileDialogPeer {
|
||||
if (visible) {
|
||||
// Java2 Dialog class requires peer to run code in a separate thread
|
||||
// and handles keeping the call modal
|
||||
new Thread(new Task()).start(); // invokes my 'run' method, below...
|
||||
if (System.getSecurityManager() == null) {
|
||||
new Thread(new Task()).start();
|
||||
} else {
|
||||
new ManagedLocalsThread(new Task()).start();
|
||||
}
|
||||
}
|
||||
// We hide ourself before "show" returns - setVisible(false)
|
||||
// doesn't apply
|
||||
|
@ -29,6 +29,7 @@ import java.awt.*;
|
||||
import java.awt.dnd.*;
|
||||
|
||||
import sun.lwawt.*;
|
||||
import sun.misc.ManagedLocalsThread;
|
||||
|
||||
public class CPrinterDialogPeer extends LWWindowPeer {
|
||||
static {
|
||||
@ -53,13 +54,16 @@ public class CPrinterDialogPeer extends LWWindowPeer {
|
||||
|
||||
public void setVisible(boolean visible) {
|
||||
if (visible) {
|
||||
new Thread(new Runnable() {
|
||||
public void run() {
|
||||
CPrinterDialog printerDialog = (CPrinterDialog)fTarget;
|
||||
printerDialog.setRetVal(printerDialog.showDialog());
|
||||
printerDialog.setVisible(false);
|
||||
}
|
||||
}).start();
|
||||
Runnable task = () -> {
|
||||
CPrinterDialog printerDialog = (CPrinterDialog)fTarget;
|
||||
printerDialog.setRetVal(printerDialog.showDialog());
|
||||
printerDialog.setVisible(false);
|
||||
};
|
||||
if (System.getSecurityManager() == null) {
|
||||
new Thread(task).start();
|
||||
} else {
|
||||
new ManagedLocalsThread(task).start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,6 +39,7 @@ import javax.print.attribute.HashPrintRequestAttributeSet;
|
||||
import javax.print.attribute.standard.PageRanges;
|
||||
|
||||
import sun.java2d.*;
|
||||
import sun.misc.ManagedLocalsThread;
|
||||
import sun.print.*;
|
||||
|
||||
public final class CPrinterJob extends RasterPrinterJob {
|
||||
@ -731,9 +732,12 @@ public final class CPrinterJob extends RasterPrinterJob {
|
||||
|
||||
// upcall from native
|
||||
private static void detachPrintLoop(final long target, final long arg) {
|
||||
new Thread() { public void run() {
|
||||
_safePrintLoop(target, arg);
|
||||
}}.start();
|
||||
Runnable task = () -> _safePrintLoop(target, arg);
|
||||
if (System.getSecurityManager() == null) {
|
||||
new Thread(task).start();
|
||||
} else {
|
||||
new ManagedLocalsThread(task).start();
|
||||
}
|
||||
}
|
||||
private static native void _safePrintLoop(long target, long arg);
|
||||
|
||||
|
@ -25,7 +25,12 @@
|
||||
|
||||
package com.sun.imageio.stream;
|
||||
|
||||
import sun.awt.util.ThreadGroupUtils;
|
||||
import sun.misc.InnocuousThread;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.Set;
|
||||
import java.util.WeakHashMap;
|
||||
import javax.imageio.stream.ImageInputStream;
|
||||
@ -81,27 +86,25 @@ public class StreamCloser {
|
||||
}
|
||||
};
|
||||
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<Object>() {
|
||||
public Object run() {
|
||||
/* The thread must be a member of a thread group
|
||||
* which will not get GCed before VM exit.
|
||||
* Make its parent the top-level thread group.
|
||||
*/
|
||||
ThreadGroup tg =
|
||||
Thread.currentThread().getThreadGroup();
|
||||
for (ThreadGroup tgn = tg;
|
||||
tgn != null;
|
||||
tg = tgn, tgn = tg.getParent());
|
||||
streamCloser = new Thread(tg, streamCloserRunnable);
|
||||
/* Set context class loader to null in order to avoid
|
||||
* keeping a strong reference to an application classloader.
|
||||
*/
|
||||
streamCloser.setContextClassLoader(null);
|
||||
Runtime.getRuntime().addShutdownHook(streamCloser);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
AccessController.doPrivileged((PrivilegedAction<Object>) () -> {
|
||||
if (System.getSecurityManager() == null) {
|
||||
/* The thread must be a member of a thread group
|
||||
* which will not get GCed before VM exit.
|
||||
* Make its parent the top-level thread group.
|
||||
*/
|
||||
ThreadGroup tg = ThreadGroupUtils.getRootThreadGroup();
|
||||
streamCloser = new Thread(tg, streamCloserRunnable);
|
||||
} else {
|
||||
/* InnocuousThread is a member of a correct TG by default */
|
||||
streamCloser = new InnocuousThread(streamCloserRunnable);
|
||||
}
|
||||
/* Set context class loader to null in order to avoid
|
||||
* keeping a strong reference to an application classloader.
|
||||
*/
|
||||
streamCloser.setContextClassLoader(null);
|
||||
Runtime.getRuntime().addShutdownHook(streamCloser);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -64,6 +64,7 @@ import sun.awt.SunToolkit;
|
||||
import sun.awt.OSInfo;
|
||||
import sun.awt.shell.ShellFolder;
|
||||
import sun.font.FontUtilities;
|
||||
import sun.misc.ManagedLocalsThread;
|
||||
import sun.security.action.GetPropertyAction;
|
||||
|
||||
import sun.swing.DefaultLayoutStyle;
|
||||
@ -2037,7 +2038,11 @@ public class WindowsLookAndFeel extends BasicLookAndFeel
|
||||
if (audioRunnable != null) {
|
||||
// Runnable appears to block until completed playing, hence
|
||||
// start up another thread to handle playing.
|
||||
new Thread(audioRunnable).start();
|
||||
if (System.getSecurityManager() == null) {
|
||||
new Thread(audioRunnable).start();
|
||||
} else {
|
||||
new ManagedLocalsThread(audioRunnable).start();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,9 @@
|
||||
|
||||
package com.sun.media.sound;
|
||||
|
||||
import sun.misc.InnocuousThread;
|
||||
import sun.misc.ManagedLocalsThread;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.File;
|
||||
@ -144,7 +147,13 @@ final class JSSecurityManager {
|
||||
final String threadName,
|
||||
final boolean isDaemon, final int priority,
|
||||
final boolean doStart) {
|
||||
Thread thread = new Thread(runnable);
|
||||
Thread thread;
|
||||
if (System.getSecurityManager() == null) {
|
||||
thread = new Thread(runnable);
|
||||
} else {
|
||||
thread = new ManagedLocalsThread(runnable);
|
||||
}
|
||||
|
||||
if (threadName != null) {
|
||||
thread.setName(threadName);
|
||||
}
|
||||
|
@ -24,6 +24,8 @@
|
||||
*/
|
||||
package com.sun.media.sound;
|
||||
|
||||
import sun.misc.ManagedLocalsThread;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.sound.sampled.AudioInputStream;
|
||||
@ -53,7 +55,11 @@ public final class SoftAudioPusher implements Runnable {
|
||||
if (active)
|
||||
return;
|
||||
active = true;
|
||||
audiothread = new Thread(this);
|
||||
if (System.getSecurityManager() == null) {
|
||||
audiothread = new Thread(this);
|
||||
} else {
|
||||
audiothread = new ManagedLocalsThread(this);
|
||||
}
|
||||
audiothread.setDaemon(true);
|
||||
audiothread.setPriority(Thread.MAX_PRIORITY);
|
||||
audiothread.start();
|
||||
|
@ -24,12 +24,13 @@
|
||||
*/
|
||||
package com.sun.media.sound;
|
||||
|
||||
import java.io.EOFException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import sun.misc.ManagedLocalsThread;
|
||||
|
||||
import javax.sound.sampled.AudioFormat;
|
||||
import javax.sound.sampled.AudioInputStream;
|
||||
import java.io.EOFException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* A jitter corrector to be used with SoftAudioPusher.
|
||||
@ -215,7 +216,11 @@ public final class SoftJitterCorrector extends AudioInputStream {
|
||||
}
|
||||
};
|
||||
|
||||
thread = new Thread(runnable);
|
||||
if (System.getSecurityManager() == null) {
|
||||
thread = new Thread(runnable);
|
||||
} else {
|
||||
thread = new ManagedLocalsThread(runnable);
|
||||
}
|
||||
thread.setDaemon(true);
|
||||
thread.setPriority(Thread.MAX_PRIORITY);
|
||||
thread.start();
|
||||
|
@ -25,6 +25,8 @@
|
||||
|
||||
package com.sun.media.sound;
|
||||
|
||||
import sun.misc.ManagedLocalsThread;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@ -139,7 +141,11 @@ public final class SoftSynthesizer implements AudioSynthesizer,
|
||||
pusher = null;
|
||||
jitter_stream = null;
|
||||
sourceDataLine = null;
|
||||
new Thread(runnable).start();
|
||||
if (System.getSecurityManager() == null) {
|
||||
new Thread(runnable).start();
|
||||
} else {
|
||||
new ManagedLocalsThread(runnable).start();
|
||||
}
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
@ -30,6 +30,8 @@ import java.awt.event.ActionEvent;
|
||||
import java.awt.event.WindowEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import sun.misc.ManagedLocalsThread;
|
||||
import sun.util.logging.PlatformLogger;
|
||||
|
||||
import sun.awt.dnd.SunDragSourceContextPeer;
|
||||
@ -53,7 +55,7 @@ import sun.awt.dnd.SunDragSourceContextPeer;
|
||||
*
|
||||
* @since 1.1
|
||||
*/
|
||||
class EventDispatchThread extends Thread {
|
||||
class EventDispatchThread extends ManagedLocalsThread {
|
||||
|
||||
private static final PlatformLogger eventLog = PlatformLogger.getLogger("java.awt.event.EventDispatchThread");
|
||||
|
||||
@ -65,7 +67,7 @@ class EventDispatchThread extends Thread {
|
||||
private ArrayList<EventFilter> eventFilters = new ArrayList<EventFilter>();
|
||||
|
||||
EventDispatchThread(ThreadGroup group, String name, EventQueue queue) {
|
||||
super(group, name);
|
||||
super(group, null, name);
|
||||
setEventQueue(queue);
|
||||
}
|
||||
|
||||
|
@ -34,10 +34,11 @@
|
||||
**********************************************************************/
|
||||
|
||||
package java.awt.image.renderable;
|
||||
import java.awt.color.ColorSpace;
|
||||
|
||||
import sun.misc.ManagedLocalsThread;
|
||||
|
||||
import java.awt.image.ColorModel;
|
||||
import java.awt.image.DataBuffer;
|
||||
import java.awt.image.DirectColorModel;
|
||||
import java.awt.image.ImageConsumer;
|
||||
import java.awt.image.ImageProducer;
|
||||
import java.awt.image.Raster;
|
||||
@ -135,7 +136,13 @@ public class RenderableImageProducer implements ImageProducer, Runnable {
|
||||
public synchronized void startProduction(ImageConsumer ic) {
|
||||
addConsumer(ic);
|
||||
// Need to build a runnable object for the Thread.
|
||||
Thread thread = new Thread(this, "RenderableImageProducer Thread");
|
||||
String name = "RenderableImageProducer Thread";
|
||||
Thread thread;
|
||||
if (System.getSecurityManager() == null) {
|
||||
thread = new Thread(this, name);
|
||||
} else {
|
||||
thread = new ManagedLocalsThread(this);
|
||||
}
|
||||
thread.start();
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -46,9 +46,6 @@ import java.lang.reflect.Modifier;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
|
||||
import java.util.Enumeration;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
@ -183,16 +180,10 @@ public class Beans {
|
||||
|
||||
// Try to find a serialized object with this name
|
||||
final String serName = beanName.replace('.','/').concat(".ser");
|
||||
final ClassLoader loader = cls;
|
||||
ins = AccessController.doPrivileged
|
||||
(new PrivilegedAction<InputStream>() {
|
||||
public InputStream run() {
|
||||
if (loader == null)
|
||||
return ClassLoader.getSystemResourceAsStream(serName);
|
||||
else
|
||||
return loader.getResourceAsStream(serName);
|
||||
}
|
||||
});
|
||||
if (cls == null)
|
||||
ins = ClassLoader.getSystemResourceAsStream(serName);
|
||||
else
|
||||
ins = cls.getResourceAsStream(serName);
|
||||
if (ins != null) {
|
||||
try {
|
||||
if (cls == null) {
|
||||
@ -283,19 +274,10 @@ public class Beans {
|
||||
URL docBase = null;
|
||||
|
||||
// Now get the URL correponding to the resource name.
|
||||
|
||||
final ClassLoader cloader = cls;
|
||||
objectUrl =
|
||||
AccessController.doPrivileged
|
||||
(new PrivilegedAction<URL>() {
|
||||
public URL run() {
|
||||
if (cloader == null)
|
||||
return ClassLoader.getSystemResource
|
||||
(resourceName);
|
||||
else
|
||||
return cloader.getResource(resourceName);
|
||||
}
|
||||
});
|
||||
if (cls == null) {
|
||||
objectUrl = ClassLoader.getSystemResource(resourceName);
|
||||
} else
|
||||
objectUrl = cls.getResource(resourceName);
|
||||
|
||||
// If we found a URL, we try to locate the docbase by taking
|
||||
// of the final path name component, and the code base by taking
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,6 +25,11 @@
|
||||
|
||||
package java.beans;
|
||||
|
||||
import java.awt.Image;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.image.ImageProducer;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* This is a support class to make it easier for people to provide
|
||||
* BeanInfo classes.
|
||||
@ -101,7 +106,7 @@ public class SimpleBeanInfo implements BeanInfo {
|
||||
* Claim there are no icons available. You can override
|
||||
* this if you want to provide icons for your bean.
|
||||
*/
|
||||
public java.awt.Image getIcon(int iconKind) {
|
||||
public Image getIcon(int iconKind) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -116,33 +121,17 @@ public class SimpleBeanInfo implements BeanInfo {
|
||||
* "wombat.gif".
|
||||
* @return an image object. May be null if the load failed.
|
||||
*/
|
||||
public java.awt.Image loadImage(final String resourceName) {
|
||||
public Image loadImage(final String resourceName) {
|
||||
try {
|
||||
final Class<?> c = getClass();
|
||||
java.awt.image.ImageProducer ip = (java.awt.image.ImageProducer)
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<Object>() {
|
||||
public Object run() {
|
||||
java.net.URL url;
|
||||
if ((url = c.getResource(resourceName)) == null) {
|
||||
return null;
|
||||
} else {
|
||||
try {
|
||||
return url.getContent();
|
||||
} catch (java.io.IOException ioe) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (ip == null)
|
||||
return null;
|
||||
java.awt.Toolkit tk = java.awt.Toolkit.getDefaultToolkit();
|
||||
return tk.createImage(ip);
|
||||
} catch (Exception ex) {
|
||||
return null;
|
||||
final URL url = getClass().getResource(resourceName);
|
||||
if (url != null) {
|
||||
final ImageProducer ip = (ImageProducer) url.getContent();
|
||||
if (ip != null) {
|
||||
return Toolkit.getDefaultToolkit().createImage(ip);
|
||||
}
|
||||
}
|
||||
} catch (final Exception ignored) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -53,6 +53,8 @@ import java.util.List;
|
||||
|
||||
import javax.print.attribute.*;
|
||||
import javax.print.PrintService;
|
||||
|
||||
import sun.misc.ManagedLocalsThread;
|
||||
import sun.reflect.misc.ReflectUtil;
|
||||
|
||||
import sun.swing.SwingUtilities2;
|
||||
@ -6384,25 +6386,28 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
|
||||
|
||||
// this runnable will be used to do the printing
|
||||
// (and save any throwables) on another thread
|
||||
Runnable runnable = new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
// do the printing
|
||||
job.print(copyAttr);
|
||||
} catch (Throwable t) {
|
||||
// save any Throwable to be rethrown
|
||||
synchronized(lock) {
|
||||
printError = t;
|
||||
}
|
||||
} finally {
|
||||
// we're finished - hide the dialog
|
||||
printingStatus.dispose();
|
||||
Runnable runnable = () -> {
|
||||
try {
|
||||
// do the printing
|
||||
job.print(copyAttr);
|
||||
} catch (Throwable t) {
|
||||
// save any Throwable to be rethrown
|
||||
synchronized(lock) {
|
||||
printError = t;
|
||||
}
|
||||
} finally {
|
||||
// we're finished - hide the dialog
|
||||
printingStatus.dispose();
|
||||
}
|
||||
};
|
||||
|
||||
// start printing on another thread
|
||||
Thread th = new Thread(runnable);
|
||||
Thread th;
|
||||
if (System.getSecurityManager() == null) {
|
||||
th = new Thread(runnable);
|
||||
} else {
|
||||
th = new ManagedLocalsThread(runnable);
|
||||
}
|
||||
th.start();
|
||||
|
||||
printingStatus.showModal(true);
|
||||
|
@ -29,12 +29,14 @@ package javax.swing;
|
||||
|
||||
|
||||
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.locks.*;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import sun.awt.AppContext;
|
||||
|
||||
import sun.misc.InnocuousThread;
|
||||
|
||||
|
||||
/**
|
||||
@ -94,18 +96,19 @@ class TimerQueue implements Runnable
|
||||
if (! running) {
|
||||
runningLock.lock();
|
||||
try {
|
||||
final ThreadGroup threadGroup =
|
||||
AppContext.getAppContext().getThreadGroup();
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<Object>() {
|
||||
public Object run() {
|
||||
Thread timerThread = new Thread(threadGroup, TimerQueue.this,
|
||||
"TimerQueue");
|
||||
timerThread.setDaemon(true);
|
||||
timerThread.setPriority(Thread.NORM_PRIORITY);
|
||||
timerThread.start();
|
||||
return null;
|
||||
final ThreadGroup threadGroup = AppContext.getAppContext().getThreadGroup();
|
||||
AccessController.doPrivileged((PrivilegedAction<Object>) () -> {
|
||||
String name = "TimerQueue";
|
||||
Thread timerThread;
|
||||
if (System.getSecurityManager() == null) {
|
||||
timerThread = new Thread(threadGroup, TimerQueue.this, name);
|
||||
} else {
|
||||
timerThread = new InnocuousThread(threadGroup, TimerQueue.this, name);
|
||||
}
|
||||
timerThread.setDaemon(true);
|
||||
timerThread.setPriority(Thread.NORM_PRIORITY);
|
||||
timerThread.start();
|
||||
return null;
|
||||
});
|
||||
running = true;
|
||||
} finally {
|
||||
|
@ -25,15 +25,19 @@
|
||||
|
||||
package javax.swing.plaf.basic;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.Callable;
|
||||
import javax.swing.*;
|
||||
import javax.swing.filechooser.*;
|
||||
import javax.swing.event.*;
|
||||
import java.beans.*;
|
||||
|
||||
import sun.awt.shell.ShellFolder;
|
||||
import sun.misc.ManagedLocalsThread;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ListDataEvent;
|
||||
import javax.swing.filechooser.FileSystemView;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.beans.PropertyChangeSupport;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
/**
|
||||
* Basic implementation of a file list.
|
||||
@ -46,7 +50,7 @@ public class BasicDirectoryModel extends AbstractListModel<Object> implements Pr
|
||||
private JFileChooser filechooser = null;
|
||||
// PENDING(jeff) pick the size more sensibly
|
||||
private Vector<File> fileCache = new Vector<File>(50);
|
||||
private LoadFilesThread loadThread = null;
|
||||
private FilesLoader filesLoader = null;
|
||||
private Vector<File> files = null;
|
||||
private Vector<File> directories = null;
|
||||
private int fetchID = 0;
|
||||
@ -91,10 +95,10 @@ public class BasicDirectoryModel extends AbstractListModel<Object> implements Pr
|
||||
* This method is used to interrupt file loading thread.
|
||||
*/
|
||||
public void invalidateFileCache() {
|
||||
if (loadThread != null) {
|
||||
loadThread.interrupt();
|
||||
loadThread.cancelRunnables();
|
||||
loadThread = null;
|
||||
if (filesLoader != null) {
|
||||
filesLoader.loadThread.interrupt();
|
||||
filesLoader.cancelRunnables();
|
||||
filesLoader = null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -149,15 +153,14 @@ public class BasicDirectoryModel extends AbstractListModel<Object> implements Pr
|
||||
if (currentDirectory == null) {
|
||||
return;
|
||||
}
|
||||
if (loadThread != null) {
|
||||
loadThread.interrupt();
|
||||
loadThread.cancelRunnables();
|
||||
if (filesLoader != null) {
|
||||
filesLoader.loadThread.interrupt();
|
||||
filesLoader.cancelRunnables();
|
||||
}
|
||||
|
||||
setBusy(true, ++fetchID);
|
||||
|
||||
loadThread = new LoadFilesThread(currentDirectory, fetchID);
|
||||
loadThread.start();
|
||||
filesLoader = new FilesLoader(currentDirectory, fetchID);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -258,17 +261,25 @@ public class BasicDirectoryModel extends AbstractListModel<Object> implements Pr
|
||||
}
|
||||
|
||||
|
||||
class LoadFilesThread extends Thread {
|
||||
class FilesLoader implements Runnable {
|
||||
File currentDirectory = null;
|
||||
int fid;
|
||||
Vector<DoChangeContents> runnables = new Vector<DoChangeContents>(10);
|
||||
final Thread loadThread;
|
||||
|
||||
public LoadFilesThread(File currentDirectory, int fid) {
|
||||
super("Basic L&F File Loading Thread");
|
||||
public FilesLoader(File currentDirectory, int fid) {
|
||||
this.currentDirectory = currentDirectory;
|
||||
this.fid = fid;
|
||||
String name = "Basic L&F File Loading Thread";
|
||||
if (System.getSecurityManager() == null) {
|
||||
this.loadThread = new Thread(this, name);
|
||||
} else {
|
||||
this.loadThread = new ManagedLocalsThread(this, name);
|
||||
}
|
||||
this.loadThread.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
run0();
|
||||
setBusy(false, fid);
|
||||
@ -277,13 +288,13 @@ public class BasicDirectoryModel extends AbstractListModel<Object> implements Pr
|
||||
public void run0() {
|
||||
FileSystemView fileSystem = filechooser.getFileSystemView();
|
||||
|
||||
if (isInterrupted()) {
|
||||
if (loadThread.isInterrupted()) {
|
||||
return;
|
||||
}
|
||||
|
||||
File[] list = fileSystem.getFiles(currentDirectory, filechooser.isFileHidingEnabled());
|
||||
|
||||
if (isInterrupted()) {
|
||||
if (loadThread.isInterrupted()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -303,7 +314,7 @@ public class BasicDirectoryModel extends AbstractListModel<Object> implements Pr
|
||||
newFiles.addElement(file);
|
||||
}
|
||||
|
||||
if (isInterrupted()) {
|
||||
if (loadThread.isInterrupted()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -340,7 +351,7 @@ public class BasicDirectoryModel extends AbstractListModel<Object> implements Pr
|
||||
}
|
||||
if (start >= 0 && end > start
|
||||
&& newFileCache.subList(end, newSize).equals(fileCache.subList(start, oldSize))) {
|
||||
if (isInterrupted()) {
|
||||
if (loadThread.isInterrupted()) {
|
||||
return null;
|
||||
}
|
||||
return new DoChangeContents(newFileCache.subList(start, end), start, null, 0, fid);
|
||||
@ -358,14 +369,14 @@ public class BasicDirectoryModel extends AbstractListModel<Object> implements Pr
|
||||
}
|
||||
if (start >= 0 && end > start
|
||||
&& fileCache.subList(end, oldSize).equals(newFileCache.subList(start, newSize))) {
|
||||
if (isInterrupted()) {
|
||||
if (loadThread.isInterrupted()) {
|
||||
return null;
|
||||
}
|
||||
return new DoChangeContents(null, 0, new Vector<>(fileCache.subList(start, end)), start, fid);
|
||||
}
|
||||
}
|
||||
if (!fileCache.equals(newFileCache)) {
|
||||
if (isInterrupted()) {
|
||||
if (loadThread.isInterrupted()) {
|
||||
cancelRunnables(runnables);
|
||||
}
|
||||
return new DoChangeContents(newFileCache, 0, fileCache, 0, fid);
|
||||
|
@ -68,6 +68,7 @@ import javax.print.attribute.*;
|
||||
import sun.awt.AppContext;
|
||||
|
||||
|
||||
import sun.misc.ManagedLocalsThread;
|
||||
import sun.swing.PrintingStatus;
|
||||
import sun.swing.SwingUtilities2;
|
||||
import sun.swing.text.TextComponentPrintable;
|
||||
@ -2364,7 +2365,11 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
|
||||
runnablePrinting.run();
|
||||
} else {
|
||||
if (isEventDispatchThread) {
|
||||
(new Thread(runnablePrinting)).start();
|
||||
if (System.getSecurityManager() == null) {
|
||||
new Thread(runnablePrinting).start();
|
||||
} else {
|
||||
new ManagedLocalsThread(runnablePrinting).start();
|
||||
}
|
||||
printingStatus.showModal(true);
|
||||
} else {
|
||||
printingStatus.showModal(false);
|
||||
|
@ -26,6 +26,7 @@ package javax.swing.text;
|
||||
|
||||
import java.util.Vector;
|
||||
import sun.awt.AppContext;
|
||||
import sun.misc.ManagedLocalsThread;
|
||||
|
||||
/**
|
||||
* A queue of text layout tasks.
|
||||
@ -82,7 +83,22 @@ public class LayoutQueue {
|
||||
*/
|
||||
public synchronized void addTask(Runnable task) {
|
||||
if (worker == null) {
|
||||
worker = new LayoutThread();
|
||||
Runnable workerRunnable = () -> {
|
||||
Runnable work;
|
||||
do {
|
||||
work = waitForWork();
|
||||
if (work != null) {
|
||||
work.run();
|
||||
}
|
||||
} while (work != null);
|
||||
};
|
||||
String name = "text-layout";
|
||||
if (System.getSecurityManager() == null) {
|
||||
worker = new Thread(workerRunnable, name);
|
||||
} else {
|
||||
worker = new ManagedLocalsThread(workerRunnable, name);
|
||||
}
|
||||
worker.setPriority(Thread.MIN_PRIORITY);
|
||||
worker.start();
|
||||
}
|
||||
tasks.addElement(task);
|
||||
@ -105,28 +121,4 @@ public class LayoutQueue {
|
||||
tasks.removeElementAt(0);
|
||||
return work;
|
||||
}
|
||||
|
||||
/**
|
||||
* low priority thread to perform layout work forever
|
||||
*/
|
||||
class LayoutThread extends Thread {
|
||||
|
||||
LayoutThread() {
|
||||
super("text-layout");
|
||||
setPriority(Thread.MIN_PRIORITY);
|
||||
}
|
||||
|
||||
public void run() {
|
||||
Runnable work;
|
||||
do {
|
||||
work = waitForWork();
|
||||
if (work != null) {
|
||||
work.run();
|
||||
}
|
||||
} while (work != null);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -52,6 +52,7 @@ import java.security.PermissionCollection;
|
||||
import sun.awt.AppContext;
|
||||
import sun.awt.SunToolkit;
|
||||
import sun.misc.IOUtils;
|
||||
import sun.misc.ManagedLocalsThread;
|
||||
import sun.net.www.ParseUtil;
|
||||
import sun.security.util.SecurityConstants;
|
||||
|
||||
@ -855,13 +856,13 @@ public void grab() {
|
||||
* this operation to complete before continuing, wait for the notifyAll()
|
||||
* operation on the syncObject to occur.
|
||||
*/
|
||||
class AppContextCreator extends Thread {
|
||||
class AppContextCreator extends ManagedLocalsThread {
|
||||
Object syncObject = new Object();
|
||||
AppContext appContext = null;
|
||||
volatile boolean created = false;
|
||||
|
||||
AppContextCreator(ThreadGroup group) {
|
||||
super(group, "AppContextCreator");
|
||||
super(group, null, "AppContextCreator");
|
||||
}
|
||||
|
||||
public void run() {
|
||||
|
@ -42,6 +42,7 @@ import sun.awt.AWTAccessor;
|
||||
import sun.awt.AppContext;
|
||||
import sun.awt.EmbeddedFrame;
|
||||
import sun.awt.SunToolkit;
|
||||
import sun.misc.ManagedLocalsThread;
|
||||
import sun.misc.MessageUtils;
|
||||
import sun.misc.PerformanceLogger;
|
||||
import sun.misc.Queue;
|
||||
@ -176,8 +177,7 @@ abstract class AppletPanel extends Panel implements AppletStub, Runnable {
|
||||
|
||||
|
||||
ThreadGroup appletGroup = loader.getThreadGroup();
|
||||
|
||||
handler = new Thread(appletGroup, this, "thread " + nm);
|
||||
handler = new ManagedLocalsThread(appletGroup, this, "thread " + nm);
|
||||
// set the context class loader for this thread
|
||||
AccessController.doPrivileged(new PrivilegedAction<Object>() {
|
||||
@Override
|
||||
@ -410,7 +410,7 @@ abstract class AppletPanel extends Panel implements AppletStub, Runnable {
|
||||
if (loaderThread == null) {
|
||||
// REMIND: do we want a name?
|
||||
//System.out.println("------------------- loading applet");
|
||||
setLoaderThread(new Thread(this));
|
||||
setLoaderThread(new ManagedLocalsThread(this));
|
||||
loaderThread.start();
|
||||
// we get to go to sleep while this runs
|
||||
loaderThread.join();
|
||||
|
@ -38,6 +38,7 @@ import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import sun.awt.SunToolkit;
|
||||
import sun.awt.AppContext;
|
||||
import sun.misc.ManagedLocalsThread;
|
||||
|
||||
/**
|
||||
* A frame to show the applet tag in.
|
||||
@ -853,7 +854,7 @@ public class AppletViewer extends Frame implements AppletContext, Printable {
|
||||
//
|
||||
final AppletPanel p = panel;
|
||||
|
||||
new Thread(new Runnable()
|
||||
new ManagedLocalsThread(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
@ -889,7 +890,7 @@ public class AppletViewer extends Frame implements AppletContext, Printable {
|
||||
// spawn a new thread to avoid blocking the event queue
|
||||
// when calling appletShutdown.
|
||||
//
|
||||
new Thread(new Runnable()
|
||||
new ManagedLocalsThread(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
|
@ -34,6 +34,7 @@ import java.util.IdentityHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import sun.misc.InnocuousThread;
|
||||
import sun.util.logging.PlatformLogger;
|
||||
import sun.awt.util.ThreadGroupUtils;
|
||||
|
||||
@ -340,7 +341,13 @@ public final class AWTAutoShutdown implements Runnable {
|
||||
* Must be called with {@link sun.security.util.SecurityConstants#MODIFY_THREADGROUP_PERMISSION}
|
||||
*/
|
||||
private void activateBlockerThread() {
|
||||
Thread thread = new Thread(ThreadGroupUtils.getRootThreadGroup(), this, "AWT-Shutdown");
|
||||
Thread thread;
|
||||
String name = "AWT-Shutdown";
|
||||
if (System.getSecurityManager() == null) {
|
||||
thread = new Thread(ThreadGroupUtils.getRootThreadGroup(), this, name);
|
||||
} else {
|
||||
thread = new InnocuousThread(this, name);
|
||||
}
|
||||
thread.setContextClassLoader(null);
|
||||
thread.setDaemon(false);
|
||||
blockerThread = thread;
|
||||
|
@ -43,6 +43,8 @@ import java.util.HashSet;
|
||||
import java.beans.PropertyChangeSupport;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.lang.ref.SoftReference;
|
||||
|
||||
import sun.misc.InnocuousThread;
|
||||
import sun.util.logging.PlatformLogger;
|
||||
import java.util.concurrent.locks.Condition;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
@ -589,7 +591,12 @@ public final class AppContext {
|
||||
}
|
||||
|
||||
public Thread run() {
|
||||
Thread t = new Thread(appContext.getThreadGroup(), runnable);
|
||||
Thread t;
|
||||
if (System.getSecurityManager() == null) {
|
||||
t = new Thread(appContext.getThreadGroup(), runnable);
|
||||
} else {
|
||||
t = new InnocuousThread(appContext.getThreadGroup(), runnable, "AppContext Disposer");
|
||||
}
|
||||
t.setContextClassLoader(appContext.getContextClassLoader());
|
||||
t.setPriority(Thread.NORM_PRIORITY + 1);
|
||||
t.setDaemon(true);
|
||||
|
@ -55,6 +55,8 @@ import java.util.prefs.BackingStoreException;
|
||||
import java.util.prefs.Preferences;
|
||||
import sun.awt.InputMethodSupport;
|
||||
import sun.awt.SunToolkit;
|
||||
import sun.misc.InnocuousThread;
|
||||
import sun.misc.ManagedLocalsThread;
|
||||
|
||||
/**
|
||||
* <code>InputMethodManager</code> is an abstract class that manages the input
|
||||
@ -165,7 +167,12 @@ public abstract class InputMethodManager {
|
||||
// to choose from. Otherwise, just keep the instance.
|
||||
if (imm.hasMultipleInputMethods()) {
|
||||
imm.initialize();
|
||||
Thread immThread = new Thread(imm, threadName);
|
||||
Thread immThread;
|
||||
if (System.getSecurityManager() == null) {
|
||||
immThread = new Thread(imm, threadName);
|
||||
} else {
|
||||
immThread = new ManagedLocalsThread(imm, threadName);
|
||||
}
|
||||
immThread.setDaemon(true);
|
||||
immThread.setPriority(Thread.NORM_PRIORITY + 1);
|
||||
immThread.start();
|
||||
|
@ -27,6 +27,7 @@ package sun.awt.image;
|
||||
|
||||
import java.util.Vector;
|
||||
import sun.awt.AppContext;
|
||||
import sun.misc.ManagedLocalsThread;
|
||||
|
||||
/**
|
||||
* An ImageFetcher is a thread used to fetch ImageFetchable objects.
|
||||
@ -41,7 +42,7 @@ import sun.awt.AppContext;
|
||||
* @author Jim Graham
|
||||
* @author Fred Ecks
|
||||
*/
|
||||
class ImageFetcher extends Thread {
|
||||
class ImageFetcher extends ManagedLocalsThread {
|
||||
static final int HIGH_PRIORITY = 8;
|
||||
static final int LOW_PRIORITY = 3;
|
||||
static final int ANIM_PRIORITY = 2;
|
||||
@ -54,7 +55,7 @@ class ImageFetcher extends Thread {
|
||||
* Constructor for ImageFetcher -- only called by add() below.
|
||||
*/
|
||||
private ImageFetcher(ThreadGroup threadGroup, int index) {
|
||||
super(threadGroup, "Image Fetcher " + index);
|
||||
super(threadGroup, null, "Image Fetcher " + index);
|
||||
setDaemon(true);
|
||||
}
|
||||
|
||||
|
@ -36,6 +36,7 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
import sun.awt.AppContext;
|
||||
import sun.awt.util.ThreadGroupUtils;
|
||||
import sun.misc.InnocuousThread;
|
||||
|
||||
public class CreatedFontTracker {
|
||||
|
||||
@ -115,18 +116,25 @@ public class CreatedFontTracker {
|
||||
static void init() {
|
||||
if (t == null) {
|
||||
// Add a shutdown hook to remove the temp file.
|
||||
AccessController.doPrivileged(
|
||||
(PrivilegedAction<Void>) () -> {
|
||||
/* The thread must be a member of a thread group
|
||||
* which will not get GCed before VM exit.
|
||||
* Make its parent the top-level thread group.
|
||||
*/
|
||||
ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
|
||||
t = new Thread(rootTG, TempFileDeletionHook::runHooks);
|
||||
t.setContextClassLoader(null);
|
||||
Runtime.getRuntime().addShutdownHook(t);
|
||||
return null;
|
||||
});
|
||||
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
|
||||
if (System.getSecurityManager() == null) {
|
||||
/* The thread must be a member of a thread group
|
||||
* which will not get GCed before VM exit.
|
||||
* Make its parent the top-level thread group.
|
||||
*/
|
||||
ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
|
||||
t = new Thread(rootTG, TempFileDeletionHook::runHooks);
|
||||
} else {
|
||||
/* InnocuousThread is a member of a correct TG by default */
|
||||
t = new InnocuousThread(TempFileDeletionHook::runHooks);
|
||||
}
|
||||
/* Set context class loader to null in order to avoid
|
||||
* keeping a strong reference to an application classloader.
|
||||
*/
|
||||
t.setContextClassLoader(null);
|
||||
Runtime.getRuntime().addShutdownHook(t);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -54,6 +54,7 @@ import sun.awt.FontConfiguration;
|
||||
import sun.awt.SunToolkit;
|
||||
import sun.awt.util.ThreadGroupUtils;
|
||||
import sun.java2d.FontSupport;
|
||||
import sun.misc.InnocuousThread;
|
||||
import sun.util.logging.PlatformLogger;
|
||||
|
||||
/**
|
||||
@ -2499,18 +2500,17 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
||||
});
|
||||
}
|
||||
};
|
||||
AccessController.doPrivileged(
|
||||
(PrivilegedAction<Void>) () -> {
|
||||
/* The thread must be a member of a thread group
|
||||
* which will not get GCed before VM exit.
|
||||
* Make its parent the top-level thread group.
|
||||
*/
|
||||
ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
|
||||
fileCloser = new Thread(rootTG, fileCloserRunnable);
|
||||
fileCloser.setContextClassLoader(null);
|
||||
Runtime.getRuntime().addShutdownHook(fileCloser);
|
||||
return null;
|
||||
});
|
||||
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
|
||||
if (System.getSecurityManager() == null) {
|
||||
ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
|
||||
fileCloser = new Thread(rootTG, fileCloserRunnable);
|
||||
} else {
|
||||
fileCloser = new InnocuousThread(fileCloserRunnable);
|
||||
}
|
||||
fileCloser.setContextClassLoader(null);
|
||||
Runtime.getRuntime().addShutdownHook(fileCloser);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,7 @@
|
||||
package sun.java2d;
|
||||
|
||||
import sun.awt.util.ThreadGroupUtils;
|
||||
import sun.misc.InnocuousThread;
|
||||
|
||||
import java.lang.ref.Reference;
|
||||
import java.lang.ref.ReferenceQueue;
|
||||
@ -81,21 +82,21 @@ public class Disposer implements Runnable {
|
||||
}
|
||||
}
|
||||
disposerInstance = new Disposer();
|
||||
AccessController.doPrivileged(
|
||||
(PrivilegedAction<Void>) () -> {
|
||||
/* The thread must be a member of a thread group
|
||||
* which will not get GCed before VM exit.
|
||||
* Make its parent the top-level thread group.
|
||||
*/
|
||||
ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
|
||||
Thread t = new Thread(rootTG, disposerInstance, "Java2D Disposer");
|
||||
t.setContextClassLoader(null);
|
||||
t.setDaemon(true);
|
||||
t.setPriority(Thread.MAX_PRIORITY);
|
||||
t.start();
|
||||
return null;
|
||||
}
|
||||
);
|
||||
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
|
||||
String name = "Java2D Disposer";
|
||||
Thread t;
|
||||
if (System.getSecurityManager() == null) {
|
||||
ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
|
||||
t = new Thread(rootTG, disposerInstance, name);
|
||||
} else {
|
||||
t = new InnocuousThread(disposerInstance, name);
|
||||
}
|
||||
t.setContextClassLoader(null);
|
||||
t.setDaemon(true);
|
||||
t.setPriority(Thread.MAX_PRIORITY);
|
||||
t.start();
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -33,6 +33,7 @@ import java.awt.image.BufferedImage;
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.Rectangle;
|
||||
import sun.awt.image.BufImgSurfaceData;
|
||||
import sun.awt.util.ThreadGroupUtils;
|
||||
import sun.java2d.SurfaceData;
|
||||
import sun.java2d.pipe.Region;
|
||||
import java.lang.reflect.Field;
|
||||
@ -46,6 +47,8 @@ import java.io.FileOutputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
|
||||
import sun.misc.InnocuousThread;
|
||||
import sun.security.action.GetPropertyAction;
|
||||
|
||||
/**
|
||||
@ -413,15 +416,19 @@ public abstract class GraphicsPrimitive {
|
||||
return traceout;
|
||||
}
|
||||
|
||||
public static class TraceReporter extends Thread {
|
||||
public static class TraceReporter implements Runnable {
|
||||
public static void setShutdownHook() {
|
||||
AccessController.doPrivileged(new PrivilegedAction<Void>() {
|
||||
public Void run() {
|
||||
TraceReporter t = new TraceReporter();
|
||||
t.setContextClassLoader(null);
|
||||
Runtime.getRuntime().addShutdownHook(t);
|
||||
return null;
|
||||
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
|
||||
TraceReporter t = new TraceReporter();
|
||||
Thread thread;
|
||||
if (System.getSecurityManager() == null) {
|
||||
thread = new Thread(ThreadGroupUtils.getRootThreadGroup(), t);
|
||||
} else {
|
||||
thread = new InnocuousThread(t);
|
||||
}
|
||||
thread.setContextClassLoader(null);
|
||||
Runtime.getRuntime().addShutdownHook(thread);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,8 @@ package sun.java2d.opengl;
|
||||
import sun.awt.util.ThreadGroupUtils;
|
||||
import sun.java2d.pipe.RenderBuffer;
|
||||
import sun.java2d.pipe.RenderQueue;
|
||||
import sun.misc.InnocuousThread;
|
||||
|
||||
import static sun.java2d.pipe.BufferedOpCodes.*;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
@ -48,9 +50,7 @@ public class OGLRenderQueue extends RenderQueue {
|
||||
* The thread must be a member of a thread group
|
||||
* which will not get GCed before VM exit.
|
||||
*/
|
||||
flusher = AccessController.doPrivileged((PrivilegedAction<QueueFlusher>) () -> {
|
||||
return new QueueFlusher(ThreadGroupUtils.getRootThreadGroup());
|
||||
});
|
||||
flusher = AccessController.doPrivileged((PrivilegedAction<QueueFlusher>) QueueFlusher::new);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -115,7 +115,7 @@ public class OGLRenderQueue extends RenderQueue {
|
||||
* Returns true if the current thread is the OGL QueueFlusher thread.
|
||||
*/
|
||||
public static boolean isQueueFlusherThread() {
|
||||
return (Thread.currentThread() == getInstance().flusher);
|
||||
return (Thread.currentThread() == getInstance().flusher.thread);
|
||||
}
|
||||
|
||||
public void flushNow() {
|
||||
@ -153,16 +153,22 @@ public class OGLRenderQueue extends RenderQueue {
|
||||
refSet.clear();
|
||||
}
|
||||
|
||||
private class QueueFlusher extends Thread {
|
||||
private class QueueFlusher implements Runnable {
|
||||
private boolean needsFlush;
|
||||
private Runnable task;
|
||||
private Error error;
|
||||
private final Thread thread;
|
||||
|
||||
public QueueFlusher(ThreadGroup threadGroup) {
|
||||
super(threadGroup, "Java2D Queue Flusher");
|
||||
setDaemon(true);
|
||||
setPriority(Thread.MAX_PRIORITY);
|
||||
start();
|
||||
public QueueFlusher() {
|
||||
String name = "Java2D Queue Flusher";
|
||||
if (System.getSecurityManager() == null) {
|
||||
this.thread = new Thread(ThreadGroupUtils.getRootThreadGroup(), this, name);
|
||||
} else {
|
||||
this.thread = new InnocuousThread(this, name);
|
||||
}
|
||||
thread.setDaemon(true);
|
||||
thread.setPriority(Thread.MAX_PRIORITY);
|
||||
thread.start();
|
||||
}
|
||||
|
||||
public synchronized void flushNow() {
|
||||
|
@ -71,6 +71,7 @@ import javax.print.attribute.standard.OrientationRequested;
|
||||
import javax.print.attribute.standard.MediaSizeName;
|
||||
import javax.print.attribute.standard.PageRanges;
|
||||
|
||||
import sun.misc.ManagedLocalsThread;
|
||||
import sun.print.SunPageSelection;
|
||||
import sun.print.SunMinMaxPage;
|
||||
|
||||
@ -986,8 +987,12 @@ public class PrintJob2D extends PrintJob implements Printable, Runnable {
|
||||
}
|
||||
|
||||
private void startPrinterJobThread() {
|
||||
|
||||
printerJobThread = new Thread(this, "printerJobThread");
|
||||
String name = "printerJobThread";
|
||||
if (System.getSecurityManager() == null) {
|
||||
printerJobThread = new Thread(this, name);
|
||||
} else {
|
||||
printerJobThread = new ManagedLocalsThread(this, name);
|
||||
}
|
||||
printerJobThread.start();
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,8 @@
|
||||
|
||||
package sun.print;
|
||||
|
||||
import sun.misc.ManagedLocalsThread;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import javax.print.PrintService;
|
||||
@ -40,7 +42,7 @@ import javax.print.event.PrintServiceAttributeListener;
|
||||
* to obtain the state of the attributes and notifies the listeners of
|
||||
* any changes.
|
||||
*/
|
||||
class ServiceNotifier extends Thread {
|
||||
class ServiceNotifier extends ManagedLocalsThread {
|
||||
|
||||
private PrintService service;
|
||||
private Vector<PrintServiceAttributeListener> listeners;
|
||||
@ -48,7 +50,7 @@ class ServiceNotifier extends Thread {
|
||||
private PrintServiceAttributeSet lastSet;
|
||||
|
||||
ServiceNotifier(PrintService service) {
|
||||
super(service.getName() + " notifier");
|
||||
super((Runnable) null, service.getName() + " notifier");
|
||||
this.service = service;
|
||||
listeners = new Vector<>();
|
||||
try {
|
||||
|
@ -150,8 +150,8 @@ public:
|
||||
if(isEmpty()) {
|
||||
//err = LE_MISSING_FONT_TABLE_ERROR;
|
||||
clear(); // it's just empty. Not an error.
|
||||
} else if(offset >= fParent->fLength) {
|
||||
LE_DEBUG_TR3("offset out of range: (%p) +%d", NULL, offset);
|
||||
} else if(offset >= fParent->fLength || (offset & 0x01)) {
|
||||
LE_DEBUG_TR3("offset out of range or odd alignment: (%p) +%d", NULL, offset);
|
||||
err = LE_INDEX_OUT_OF_BOUNDS_ERROR;
|
||||
clear();
|
||||
} else {
|
||||
|
@ -115,7 +115,7 @@ ByteOffset LigatureSubstitutionProcessor::processStateEntry(LEGlyphStorage &glyp
|
||||
LE_DEBUG_BAD_FONT("off end of ligature substitution header");
|
||||
return newState; // get out! bad font
|
||||
}
|
||||
if(componentGlyph > glyphStorage.getGlyphCount()) {
|
||||
if(componentGlyph >= glyphStorage.getGlyphCount()) {
|
||||
LE_DEBUG_BAD_FONT("preposterous componentGlyph");
|
||||
currGlyph++;
|
||||
return newState; // get out! bad font
|
||||
|
@ -119,7 +119,7 @@ le_uint16 LigatureSubstitutionProcessor2::processStateEntry(LEGlyphStorage &glyp
|
||||
|
||||
offset = action & lafComponentOffsetMask;
|
||||
if (offset != 0) {
|
||||
if(componentGlyph > glyphStorage.getGlyphCount()) {
|
||||
if(componentGlyph >= glyphStorage.getGlyphCount()) {
|
||||
LE_DEBUG_BAD_FONT("preposterous componentGlyph");
|
||||
currGlyph+= dir;
|
||||
return nextStateIndex; // get out! bad font
|
||||
|
@ -58,7 +58,7 @@ le_uint32 LigatureSubstitutionSubtable::process(const LETableReference &base, Gl
|
||||
if( LE_FAILURE(success) ) { return 0; }
|
||||
le_uint16 ligCount = SWAPW(ligSetTable->ligatureCount);
|
||||
|
||||
LEReferenceTo<Offset> ligatureTableOffsetArray(base, success, ligSetTable->ligatureTableOffsetArray, ligCount);
|
||||
LEReferenceToArrayOf<Offset> ligatureTableOffsetArray(base, success, ligSetTable->ligatureTableOffsetArray, ligCount);
|
||||
for (le_uint16 lig = 0; LE_SUCCESS(success) && lig < ligCount; lig += 1) {
|
||||
Offset ligTableOffset = SWAPW(ligSetTable->ligatureTableOffsetArray[lig]);
|
||||
LEReferenceTo<LigatureTable> ligTable(ligSetTable, success, ligTableOffset);
|
||||
|
@ -255,6 +255,7 @@ LookupProcessor::LookupProcessor(const LETableReference &baseAddress,
|
||||
|
||||
if (requiredFeatureIndex != 0xFFFF) {
|
||||
requiredFeatureTable = featureListTable->getFeatureTable(featureListTable, requiredFeatureIndex, &requiredFeatureTag, success);
|
||||
if (LE_FAILURE(success)) return;
|
||||
featureReferences += SWAPW(requiredFeatureTable->lookupCount);
|
||||
}
|
||||
|
||||
@ -292,7 +293,7 @@ LookupProcessor::LookupProcessor(const LETableReference &baseAddress,
|
||||
}
|
||||
|
||||
featureTable = featureListTable->getFeatureTable(featureListTable, featureIndex, &featureTag, success);
|
||||
|
||||
if (LE_FAILURE(success)) continue;
|
||||
if (featureTag == fm.tag) {
|
||||
count += selectLookups(featureTable, fm.mask, order + count, success);
|
||||
}
|
||||
@ -319,7 +320,7 @@ LookupProcessor::LookupProcessor(const LETableReference &baseAddress,
|
||||
#endif
|
||||
|
||||
featureTable = featureListTable->getFeatureTable(featureListTable, featureIndex, &featureTag, success);
|
||||
|
||||
if (LE_FAILURE(success)) continue;
|
||||
if (featureTag == fm.tag) {
|
||||
order += selectLookups(featureTable, fm.mask, order, success);
|
||||
}
|
||||
|
@ -71,7 +71,12 @@ le_uint32 MultipleSubstitutionSubtable::process(const LETableReference &base, Gl
|
||||
if (coverageIndex >= 0 && coverageIndex < seqCount) {
|
||||
Offset sequenceTableOffset = SWAPW(sequenceTableOffsetArray[coverageIndex]);
|
||||
LEReferenceTo<SequenceTable> sequenceTable(base, success, sequenceTableOffset);
|
||||
if (LE_FAILURE(success)) {
|
||||
return 0;
|
||||
}
|
||||
le_uint16 glyphCount = SWAPW(sequenceTable->glyphCount);
|
||||
LEReferenceToArrayOf<Offset>
|
||||
substituteArrayRef(base, success, sequenceTable->substituteArray, glyphCount);
|
||||
|
||||
if (glyphCount == 0) {
|
||||
glyphIterator->setCurrGlyphID(0xFFFF);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -10,8 +10,8 @@ this sentence.
|
||||
|
||||
This code is released under the libpng license.
|
||||
|
||||
libpng versions 1.2.6, August 15, 2004, through 1.5.4, July 7, 2011, are
|
||||
Copyright (c) 2004, 2006-2011 Glenn Randers-Pehrson, and are
|
||||
libpng versions 1.2.6, August 15, 2004, through 1.6.16, December 22, 2014, are
|
||||
Copyright (c) 2004, 2006-2014 Glenn Randers-Pehrson, and are
|
||||
distributed according to the same disclaimer and license as libpng-1.2.5
|
||||
with the following individual added to the list of Contributing Authors
|
||||
|
||||
@ -108,4 +108,4 @@ certification mark of the Open Source Initiative.
|
||||
|
||||
Glenn Randers-Pehrson
|
||||
glennrp at users.sourceforge.net
|
||||
July 7, 2011
|
||||
December 22, 2014
|
||||
|
@ -1,11 +1,11 @@
|
||||
README for libpng version 1.5.4 - July 7, 2011 (shared library 15.0)
|
||||
README for libpng version 1.6.16 - December 22, 2014 (shared library 16.0)
|
||||
See the note about version numbers near the top of png.h
|
||||
|
||||
See INSTALL for instructions on how to install libpng.
|
||||
|
||||
Libpng comes in several distribution formats. Get libpng-*.tar.gz,
|
||||
libpng-*.tar.xz or libpng-*.tar.bz2 if you want UNIX-style line endings
|
||||
in the text files, or lpng*.zip if you want DOS-style line endings.
|
||||
Libpng comes in several distribution formats. Get libpng-*.tar.gz or
|
||||
libpng-*.tar.xz or if you want UNIX-style line endings in the text files,
|
||||
or lpng*.7z or lpng*.zip if you want DOS-style line endings.
|
||||
|
||||
Version 0.89 was the first official release of libpng. Don't let the
|
||||
fact that it's the first release fool you. The libpng library has been in
|
||||
@ -23,18 +23,25 @@ earlier versions if you are using a shared library. The type of the
|
||||
png_uint_32, which will affect shared-library applications that use
|
||||
this function.
|
||||
|
||||
To avoid problems with changes to the internals of png_info_struct,
|
||||
To avoid problems with changes to the internals of png info_struct,
|
||||
new APIs have been made available in 0.95 to avoid direct application
|
||||
access to info_ptr. These functions are the png_set_<chunk> and
|
||||
png_get_<chunk> functions. These functions should be used when
|
||||
accessing/storing the info_struct data, rather than manipulating it
|
||||
directly, to avoid such problems in the future.
|
||||
|
||||
It is important to note that the APIs do not make current programs
|
||||
It is important to note that the APIs did not make current programs
|
||||
that access the info struct directly incompatible with the new
|
||||
library. However, it is strongly suggested that new programs use
|
||||
the new APIs (as shown in example.c and pngtest.c), and older programs
|
||||
be converted to the new format, to facilitate upgrades in the future.
|
||||
library, through libpng-1.2.x. In libpng-1.4.x, which was meant to
|
||||
be a transitional release, members of the png_struct and the
|
||||
info_struct can still be accessed, but the compiler will issue a
|
||||
warning about deprecated usage. Since libpng-1.5.0, direct access
|
||||
to these structs is not allowed, and the definitions of the structs
|
||||
reside in private pngstruct.h and pnginfo.h header files that are not
|
||||
accessible to applications. It is strongly suggested that new
|
||||
programs use the new APIs (as shown in example.c and pngtest.c), and
|
||||
older programs be converted to the new format, to facilitate upgrades
|
||||
in the future.
|
||||
****
|
||||
|
||||
Additions since 0.90 include the ability to compile libpng as a
|
||||
@ -77,17 +84,21 @@ compression library that is useful for more things than just PNG files.
|
||||
You can use zlib as a drop-in replacement for fread() and fwrite() if
|
||||
you are so inclined.
|
||||
|
||||
zlib should be available at the same place that libpng is, or at.
|
||||
ftp://ftp.info-zip.org/pub/infozip/zlib
|
||||
zlib should be available at the same place that libpng is, or at zlib.net.
|
||||
|
||||
You may also want a copy of the PNG specification. It is available
|
||||
as an RFC, a W3C Recommendation, and an ISO/IEC Standard. You can find
|
||||
these at http://www.libpng.org/pub/png/documents/
|
||||
|
||||
This code is currently being archived at libpng.sf.net in the
|
||||
[DOWNLOAD] area, and on CompuServe, Lib 20 (PNG SUPPORT)
|
||||
at GO GRAPHSUP. If you can't find it in any of those places,
|
||||
e-mail me, and I'll help you find it.
|
||||
[DOWNLOAD] area, and at ftp://ftp.simplesystems.org. If you can't find it
|
||||
in any of those places, e-mail me, and I'll help you find it.
|
||||
|
||||
I am not a lawyer, but I believe that the Export Control Classification
|
||||
Number (ECCN) for libpng is EAR99, which means not subject to export
|
||||
controls or International Traffic in Arms Regulations (ITAR) because it
|
||||
is open source, publicly available software, that does not contain any
|
||||
encryption software. See the EAR, paragraphs 734.3(b)(3) and 734.7(b).
|
||||
|
||||
If you have any code changes, requests, problems, etc., please e-mail
|
||||
them to me. Also, I'd appreciate any make files or project files,
|
||||
@ -105,7 +116,7 @@ based in a large way on Guy's and Andreas' earlier work), and the PNG
|
||||
development group.
|
||||
|
||||
Send comments/corrections/commendations to png-mng-implement at
|
||||
lists.sourceforge.net (subscription required; visit
|
||||
lists.sourceforge.net (subscription required; visit
|
||||
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
|
||||
to subscribe) or to glennrp at users.sourceforge.net
|
||||
|
||||
@ -123,7 +134,7 @@ and ...". If in doubt, send questions to me. I'll bounce them
|
||||
to others, if necessary.
|
||||
|
||||
Please do not send suggestions on how to change PNG. We have
|
||||
been discussing PNG for sixteen years now, and it is official and
|
||||
been discussing PNG for nineteen years now, and it is official and
|
||||
finished. If you have suggestions for libpng, however, I'll
|
||||
gladly listen. Even if your suggestion is not used immediately,
|
||||
it may be used later.
|
||||
@ -167,23 +178,25 @@ Files in this distribution:
|
||||
pngwrite.c => High-level write functions
|
||||
pngwtran.c => Write data transformations
|
||||
pngwutil.c => Write utility functions
|
||||
arm => Contains optimized code for the ARM platform
|
||||
contrib => Contributions
|
||||
examples => Example programs
|
||||
gregbook => source code for PNG reading and writing, from
|
||||
Greg Roelofs' "PNG: The Definitive Guide",
|
||||
O'Reilly, 1999
|
||||
msvctest => Builds and runs pngtest using a MSVC workspace
|
||||
pngminus => Simple pnm2png and png2pnm programs
|
||||
pngsuite => Test images
|
||||
visupng => Contains a MSVC workspace for VisualPng
|
||||
libtests => Test programs
|
||||
pngminim => Minimal decoder, encoder, and progressive decoder
|
||||
programs demonstrating use of pngusr.dfa
|
||||
pngminus => Simple pnm2png and png2pnm programs
|
||||
pngsuite => Test images
|
||||
tools => Various tools
|
||||
visupng => Contains a MSVC workspace for VisualPng
|
||||
projects => Contains project files and workspaces for
|
||||
building a DLL
|
||||
cbuilder5 => Contains a Borland workspace for building
|
||||
libpng and zlib
|
||||
visualc6 => Contains a Microsoft Visual C++ (MSVC)
|
||||
workspace for building libpng and zlib
|
||||
owatcom => Contains a WATCOM project for building libpng
|
||||
visualc71 => Contains a Microsoft Visual C++ (MSVC)
|
||||
workspace for building libpng and zlib
|
||||
xcode => Contains an Apple xcode
|
||||
vstudio => Contains a Microsoft Visual C++ (MSVC)
|
||||
workspace for building libpng and zlib
|
||||
scripts => Directory containing scripts for building libpng:
|
||||
(see scripts/README.txt for the list of scripts)
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -29,9 +29,9 @@
|
||||
* However, the following notice accompanied the original version of this
|
||||
* file and, per its terms, should not be removed:
|
||||
*
|
||||
* libpng version 1.5.4 - July 7, 2011
|
||||
* libpng version 1.6.16,December 22, 2014
|
||||
*
|
||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@ -50,37 +50,73 @@
|
||||
#ifndef PNGCONF_H
|
||||
#define PNGCONF_H
|
||||
|
||||
#ifndef PNG_BUILDING_SYMBOL_TABLE
|
||||
/* PNG_NO_LIMITS_H may be used to turn off the use of the standard C
|
||||
* definition file for machine specific limits, this may impact the
|
||||
* correctness of the definitons below (see uses of INT_MAX).
|
||||
*/
|
||||
# ifndef PNG_NO_LIMITS_H
|
||||
# include <limits.h>
|
||||
/* To do: Do all of this in scripts/pnglibconf.dfa */
|
||||
#ifdef PNG_SAFE_LIMITS_SUPPORTED
|
||||
# ifdef PNG_USER_WIDTH_MAX
|
||||
# undef PNG_USER_WIDTH_MAX
|
||||
# define PNG_USER_WIDTH_MAX 1000000L
|
||||
# endif
|
||||
|
||||
/* For the memory copy APIs (i.e. the standard definitions of these),
|
||||
* because this file defines png_memcpy and so on the base APIs must
|
||||
* be defined here.
|
||||
*/
|
||||
# ifdef BSD
|
||||
# include <strings.h>
|
||||
# else
|
||||
# include <string.h>
|
||||
# ifdef PNG_USER_HEIGHT_MAX
|
||||
# undef PNG_USER_HEIGHT_MAX
|
||||
# define PNG_USER_HEIGHT_MAX 1000000L
|
||||
# endif
|
||||
|
||||
/* For png_FILE_p - this provides the standard definition of a
|
||||
* FILE
|
||||
*/
|
||||
# ifdef PNG_STDIO_SUPPORTED
|
||||
# include <stdio.h>
|
||||
# ifdef PNG_USER_CHUNK_MALLOC_MAX
|
||||
# undef PNG_USER_CHUNK_MALLOC_MAX
|
||||
# define PNG_USER_CHUNK_MALLOC_MAX 4000000L
|
||||
# endif
|
||||
# ifdef PNG_USER_CHUNK_CACHE_MAX
|
||||
# undef PNG_USER_CHUNK_CACHE_MAX
|
||||
# define PNG_USER_CHUNK_CACHE_MAX 128
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef PNG_BUILDING_SYMBOL_TABLE /* else includes may cause problems */
|
||||
|
||||
/* From libpng 1.6.0 libpng requires an ANSI X3.159-1989 ("ISOC90") compliant C
|
||||
* compiler for correct compilation. The following header files are required by
|
||||
* the standard. If your compiler doesn't provide these header files, or they
|
||||
* do not match the standard, you will need to provide/improve them.
|
||||
*/
|
||||
#include <limits.h>
|
||||
#include <stddef.h>
|
||||
|
||||
/* Library header files. These header files are all defined by ISOC90; libpng
|
||||
* expects conformant implementations, however, an ISOC90 conformant system need
|
||||
* not provide these header files if the functionality cannot be implemented.
|
||||
* In this case it will be necessary to disable the relevant parts of libpng in
|
||||
* the build of pnglibconf.h.
|
||||
*
|
||||
* Prior to 1.6.0 string.h was included here; the API changes in 1.6.0 to not
|
||||
* include this unnecessary header file.
|
||||
*/
|
||||
|
||||
#ifdef PNG_STDIO_SUPPORTED
|
||||
/* Required for the definition of FILE: */
|
||||
# include <stdio.h>
|
||||
#endif
|
||||
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
/* Required for the definition of jmp_buf and the declaration of longjmp: */
|
||||
# include <setjmp.h>
|
||||
#endif
|
||||
|
||||
#ifdef PNG_CONVERT_tIME_SUPPORTED
|
||||
/* Required for struct tm: */
|
||||
# include <time.h>
|
||||
#endif
|
||||
|
||||
#endif /* PNG_BUILDING_SYMBOL_TABLE */
|
||||
|
||||
/* Prior to 1.6.0 it was possible to turn off 'const' in declarations using
|
||||
* PNG_NO_CONST; this is no longer supported except for data declarations which
|
||||
* apparently still cause problems in 2011 on some compilers.
|
||||
*/
|
||||
#define PNG_CONST const /* backward compatibility only */
|
||||
|
||||
/* This controls optimization of the reading of 16 and 32 bit values
|
||||
* from PNG files. It can be set on a per-app-file basis - it
|
||||
* just changes whether a macro is used to the function is called.
|
||||
* The library builder sets the default, if read functions are not
|
||||
* just changes whether a macro is used when the function is called.
|
||||
* The library builder sets the default; if read functions are not
|
||||
* built into the library the macro implementation is forced on.
|
||||
*/
|
||||
#ifndef PNG_READ_INT_FUNCTIONS_SUPPORTED
|
||||
@ -100,28 +136,13 @@
|
||||
* may be changed on a per-file basis when compiling against libpng.
|
||||
*/
|
||||
|
||||
/* The PNGARG macro protects us against machines that don't have function
|
||||
* prototypes (ie K&R style headers). If your compiler does not handle
|
||||
* function prototypes, define this macro and use the included ansi2knr.
|
||||
* I've always been able to use _NO_PROTO as the indicator, but you may
|
||||
* need to drag the empty declaration out in front of here, or change the
|
||||
* ifdef to suit your own needs.
|
||||
/* The PNGARG macro was used in versions of libpng prior to 1.6.0 to protect
|
||||
* against legacy (pre ISOC90) compilers that did not understand function
|
||||
* prototypes. It is not required for modern C compilers.
|
||||
*/
|
||||
#ifndef PNGARG
|
||||
|
||||
# ifdef OF /* zlib prototype munger */
|
||||
# define PNGARG(arglist) OF(arglist)
|
||||
# else
|
||||
|
||||
# ifdef _NO_PROTO
|
||||
# define PNGARG(arglist) ()
|
||||
# else
|
||||
# define PNGARG(arglist) arglist
|
||||
# endif /* _NO_PROTO */
|
||||
|
||||
# endif /* OF */
|
||||
|
||||
#endif /* PNGARG */
|
||||
# define PNGARG(arglist) arglist
|
||||
#endif
|
||||
|
||||
/* Function calling conventions.
|
||||
* =============================
|
||||
@ -192,7 +213,9 @@
|
||||
* 'type', compiler specific.
|
||||
*
|
||||
* PNG_DLL_EXPORT Set to the magic to use during a libpng build to
|
||||
* make a symbol exported from the DLL.
|
||||
* make a symbol exported from the DLL. Not used in the
|
||||
* public header files; see pngpriv.h for how it is used
|
||||
* in the libpng build.
|
||||
*
|
||||
* PNG_DLL_IMPORT Set to the magic to force the libpng symbols to come
|
||||
* from a DLL - used to define PNG_IMPEXP when
|
||||
@ -203,18 +226,16 @@
|
||||
* ==========================
|
||||
* This code is used at build time to find PNG_IMPEXP, the API settings
|
||||
* and PNG_EXPORT_TYPE(), it may also set a macro to indicate the DLL
|
||||
* import processing is possible. On Windows/x86 systems it also sets
|
||||
* import processing is possible. On Windows systems it also sets
|
||||
* compiler-specific macros to the values required to change the calling
|
||||
* conventions of the various functions.
|
||||
*/
|
||||
#if ( defined(_Windows) || defined(_WINDOWS) || defined(WIN32) ||\
|
||||
defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) ) &&\
|
||||
( defined(_X86_) || defined(_X64_) || defined(_M_IX86) ||\
|
||||
defined(_M_X64) || defined(_M_IA64) )
|
||||
/* Windows system (DOS doesn't support DLLs) running on x86/x64. Includes
|
||||
* builds under Cygwin or MinGW. Also includes Watcom builds but these need
|
||||
* special treatment because they are not compatible with GCC or Visual C
|
||||
* because of different calling conventions.
|
||||
#if defined(_Windows) || defined(_WINDOWS) || defined(WIN32) ||\
|
||||
defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
|
||||
/* Windows system (DOS doesn't support DLLs). Includes builds under Cygwin or
|
||||
* MinGW on any architecture currently supported by Windows. Also includes
|
||||
* Watcom builds but these need special treatment because they are not
|
||||
* compatible with GCC or Visual C because of different calling conventions.
|
||||
*/
|
||||
# if PNG_API_RULE == 2
|
||||
/* If this line results in an error, either because __watcall is not
|
||||
@ -225,9 +246,12 @@
|
||||
# define PNGCAPI __watcall
|
||||
# endif
|
||||
|
||||
# if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800))
|
||||
# if defined(__GNUC__) || (defined(_MSC_VER) && (_MSC_VER >= 800))
|
||||
# define PNGCAPI __cdecl
|
||||
# if PNG_API_RULE == 1
|
||||
/* If this line results in an error __stdcall is not understood and
|
||||
* PNG_API_RULE should not have been set to '1'.
|
||||
*/
|
||||
# define PNGAPI __stdcall
|
||||
# endif
|
||||
# else
|
||||
@ -242,10 +266,11 @@
|
||||
# define PNGAPI _stdcall
|
||||
# endif
|
||||
# endif /* compiler/api */
|
||||
|
||||
/* NOTE: PNGCBAPI always defaults to PNGCAPI. */
|
||||
|
||||
# if defined(PNGAPI) && !defined(PNG_USER_PRIVATEBUILD)
|
||||
ERROR: PNG_USER_PRIVATEBUILD must be defined if PNGAPI is changed
|
||||
# error "PNG_USER_PRIVATEBUILD must be defined if PNGAPI is changed"
|
||||
# endif
|
||||
|
||||
# if (defined(_MSC_VER) && _MSC_VER < 800) ||\
|
||||
@ -265,7 +290,7 @@
|
||||
# endif
|
||||
# endif /* compiler */
|
||||
|
||||
#else /* !Windows/x86 */
|
||||
#else /* !Windows */
|
||||
# if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__)
|
||||
# define PNGAPI _System
|
||||
# else /* !Windows/x86 && !OS/2 */
|
||||
@ -286,25 +311,14 @@
|
||||
# define PNGAPI PNGCAPI
|
||||
#endif
|
||||
|
||||
/* The default for PNG_IMPEXP depends on whether the library is
|
||||
* being built or used.
|
||||
/* PNG_IMPEXP may be set on the compilation system command line or (if not set)
|
||||
* then in an internal header file when building the library, otherwise (when
|
||||
* using the library) it is set here.
|
||||
*/
|
||||
#ifndef PNG_IMPEXP
|
||||
# ifdef PNGLIB_BUILD
|
||||
/* Building the library */
|
||||
# if (defined(DLL_EXPORT)/*from libtool*/ ||\
|
||||
defined(_WINDLL) || defined(_DLL) || defined(__DLL__) ||\
|
||||
defined(_USRDLL) ||\
|
||||
defined(PNG_BUILD_DLL)) && defined(PNG_DLL_EXPORT)
|
||||
/* Building a DLL. */
|
||||
# define PNG_IMPEXP PNG_DLL_EXPORT
|
||||
# endif /* DLL */
|
||||
# else
|
||||
/* Using the library */
|
||||
# if defined(PNG_USE_DLL) && defined(PNG_DLL_IMPORT)
|
||||
/* This forces use of a DLL, disallowing static linking */
|
||||
# define PNG_IMPEXP PNG_DLL_IMPORT
|
||||
# endif
|
||||
# if defined(PNG_USE_DLL) && defined(PNG_DLL_IMPORT)
|
||||
/* This forces use of a DLL, disallowing static linking */
|
||||
# define PNG_IMPEXP PNG_DLL_IMPORT
|
||||
# endif
|
||||
|
||||
# ifndef PNG_IMPEXP
|
||||
@ -370,26 +384,48 @@
|
||||
|
||||
#ifdef PNG_PEDANTIC_WARNINGS_SUPPORTED
|
||||
/* Support for compiler specific function attributes. These are used
|
||||
* so that where compiler support is available incorrect use of API
|
||||
* so that where compiler support is available, incorrect use of API
|
||||
* functions in png.h will generate compiler warnings. Added at libpng
|
||||
* version 1.2.41.
|
||||
* version 1.2.41. Disabling these removes the warnings but may also produce
|
||||
* less efficient code.
|
||||
*/
|
||||
# if defined(__GNUC__)
|
||||
# if defined(__clang__) && defined(__has_attribute)
|
||||
/* Clang defines both __clang__ and __GNUC__. Check __clang__ first. */
|
||||
# if !defined(PNG_USE_RESULT) && __has_attribute(__warn_unused_result__)
|
||||
# define PNG_USE_RESULT __attribute__((__warn_unused_result__))
|
||||
# endif
|
||||
# if !defined(PNG_NORETURN) && __has_attribute(__noreturn__)
|
||||
# define PNG_NORETURN __attribute__((__noreturn__))
|
||||
# endif
|
||||
# if !defined(PNG_ALLOCATED) && __has_attribute(__malloc__)
|
||||
# define PNG_ALLOCATED __attribute__((__malloc__))
|
||||
# endif
|
||||
# if !defined(PNG_DEPRECATED) && __has_attribute(__deprecated__)
|
||||
# define PNG_DEPRECATED __attribute__((__deprecated__))
|
||||
# endif
|
||||
# if !defined(PNG_PRIVATE)
|
||||
# ifdef __has_extension
|
||||
# if __has_extension(attribute_unavailable_with_message)
|
||||
# define PNG_PRIVATE __attribute__((__unavailable__(\
|
||||
"This function is not exported by libpng.")))
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
# ifndef PNG_RESTRICT
|
||||
# define PNG_RESTRICT __restrict
|
||||
# endif
|
||||
|
||||
# elif defined(__GNUC__)
|
||||
# ifndef PNG_USE_RESULT
|
||||
# define PNG_USE_RESULT __attribute__((__warn_unused_result__))
|
||||
# endif
|
||||
# ifndef PNG_NORETURN
|
||||
# define PNG_NORETURN __attribute__((__noreturn__))
|
||||
# endif
|
||||
# ifndef PNG_ALLOCATED
|
||||
# define PNG_ALLOCATED __attribute__((__malloc__))
|
||||
# endif
|
||||
|
||||
/* This specifically protects structure members that should only be
|
||||
* accessed from within the library, therefore should be empty during
|
||||
* a library build.
|
||||
*/
|
||||
# ifndef PNGLIB_BUILD
|
||||
# if __GNUC__ >= 3
|
||||
# ifndef PNG_ALLOCATED
|
||||
# define PNG_ALLOCATED __attribute__((__malloc__))
|
||||
# endif
|
||||
# ifndef PNG_DEPRECATED
|
||||
# define PNG_DEPRECATED __attribute__((__deprecated__))
|
||||
# endif
|
||||
@ -402,10 +438,14 @@
|
||||
__attribute__((__deprecated__))
|
||||
# endif
|
||||
# endif
|
||||
# endif /* PNGLIB_BUILD */
|
||||
# endif /* __GNUC__ */
|
||||
# if ((__GNUC__ > 3) || !defined(__GNUC_MINOR__) || (__GNUC_MINOR__ >= 1))
|
||||
# ifndef PNG_RESTRICT
|
||||
# define PNG_RESTRICT __restrict
|
||||
# endif
|
||||
# endif /* __GNUC__.__GNUC_MINOR__ > 3.0 */
|
||||
# endif /* __GNUC__ >= 3 */
|
||||
|
||||
# if defined(_MSC_VER) && (_MSC_VER >= 1300)
|
||||
# elif defined(_MSC_VER) && (_MSC_VER >= 1300)
|
||||
# ifndef PNG_USE_RESULT
|
||||
# define PNG_USE_RESULT /* not supported */
|
||||
# endif
|
||||
@ -417,20 +457,23 @@
|
||||
# define PNG_ALLOCATED __declspec(restrict)
|
||||
# endif
|
||||
# endif
|
||||
# ifndef PNG_DEPRECATED
|
||||
# define PNG_DEPRECATED __declspec(deprecated)
|
||||
# endif
|
||||
# ifndef PNG_PRIVATE
|
||||
# define PNG_PRIVATE __declspec(deprecated)
|
||||
# endif
|
||||
# ifndef PNG_RESTRICT
|
||||
# if (_MSC_VER >= 1400)
|
||||
# define PNG_RESTRICT __restrict
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/* This specifically protects structure members that should only be
|
||||
* accessed from within the library, therefore should be empty during
|
||||
* a library build.
|
||||
*/
|
||||
# ifndef PNGLIB_BUILD
|
||||
# ifndef PNG_DEPRECATED
|
||||
# define PNG_DEPRECATED __declspec(deprecated)
|
||||
# endif
|
||||
# ifndef PNG_PRIVATE
|
||||
# define PNG_PRIVATE __declspec(deprecated)
|
||||
# endif
|
||||
# endif /* PNGLIB_BUILD */
|
||||
# endif /* _MSC_VER */
|
||||
# elif defined(__WATCOMC__)
|
||||
# ifndef PNG_RESTRICT
|
||||
# define PNG_RESTRICT __restrict
|
||||
# endif
|
||||
# endif
|
||||
#endif /* PNG_PEDANTIC_WARNINGS */
|
||||
|
||||
#ifndef PNG_DEPRECATED
|
||||
@ -448,10 +491,14 @@
|
||||
#ifndef PNG_PRIVATE
|
||||
# define PNG_PRIVATE /* This is a private libpng function */
|
||||
#endif
|
||||
#ifndef PNG_RESTRICT
|
||||
# define PNG_RESTRICT /* The C99 "restrict" feature */
|
||||
#endif
|
||||
|
||||
#ifndef PNG_FP_EXPORT /* A floating point API. */
|
||||
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
# define PNG_FP_EXPORT(ordinal, type, name, args)\
|
||||
PNG_EXPORT(ordinal, type, name, args)
|
||||
PNG_EXPORT(ordinal, type, name, args);
|
||||
# else /* No floating point APIs */
|
||||
# define PNG_FP_EXPORT(ordinal, type, name, args)
|
||||
# endif
|
||||
@ -459,189 +506,167 @@
|
||||
#ifndef PNG_FIXED_EXPORT /* A fixed point API. */
|
||||
# ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
# define PNG_FIXED_EXPORT(ordinal, type, name, args)\
|
||||
PNG_EXPORT(ordinal, type, name, args)
|
||||
PNG_EXPORT(ordinal, type, name, args);
|
||||
# else /* No fixed point APIs */
|
||||
# define PNG_FIXED_EXPORT(ordinal, type, name, args)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* The following uses const char * instead of char * for error
|
||||
* and warning message functions, so some compilers won't complain.
|
||||
* If you do not want to use const, define PNG_NO_CONST here.
|
||||
#ifndef PNG_BUILDING_SYMBOL_TABLE
|
||||
/* Some typedefs to get us started. These should be safe on most of the common
|
||||
* platforms.
|
||||
*
|
||||
* This should not change how the APIs are called, so it can be done
|
||||
* on a per-file basis in the application.
|
||||
* png_uint_32 and png_int_32 may, currently, be larger than required to hold a
|
||||
* 32-bit value however this is not normally advisable.
|
||||
*
|
||||
* png_uint_16 and png_int_16 should always be two bytes in size - this is
|
||||
* verified at library build time.
|
||||
*
|
||||
* png_byte must always be one byte in size.
|
||||
*
|
||||
* The checks below use constants from limits.h, as defined by the ISOC90
|
||||
* standard.
|
||||
*/
|
||||
#ifndef PNG_CONST
|
||||
# ifndef PNG_NO_CONST
|
||||
# define PNG_CONST const
|
||||
# else
|
||||
# define PNG_CONST
|
||||
# endif
|
||||
#if CHAR_BIT == 8 && UCHAR_MAX == 255
|
||||
typedef unsigned char png_byte;
|
||||
#else
|
||||
# error "libpng requires 8 bit bytes"
|
||||
#endif
|
||||
|
||||
/* Some typedefs to get us started. These should be safe on most of the
|
||||
* common platforms. The typedefs should be at least as large as the
|
||||
* numbers suggest (a png_uint_32 must be at least 32 bits long), but they
|
||||
* don't have to be exactly that size. Some compilers dislike passing
|
||||
* unsigned shorts as function parameters, so you may be better off using
|
||||
* unsigned int for png_uint_16.
|
||||
*/
|
||||
|
||||
#if defined(INT_MAX) && (INT_MAX > 0x7ffffffeL)
|
||||
typedef unsigned int png_uint_32;
|
||||
typedef int png_int_32;
|
||||
#if INT_MIN == -32768 && INT_MAX == 32767
|
||||
typedef int png_int_16;
|
||||
#elif SHRT_MIN == -32768 && SHRT_MAX == 32767
|
||||
typedef short png_int_16;
|
||||
#else
|
||||
typedef unsigned long png_uint_32;
|
||||
typedef long png_int_32;
|
||||
# error "libpng requires a signed 16 bit type"
|
||||
#endif
|
||||
typedef unsigned short png_uint_16;
|
||||
typedef short png_int_16;
|
||||
typedef unsigned char png_byte;
|
||||
|
||||
#ifdef PNG_NO_SIZE_T
|
||||
typedef unsigned int png_size_t;
|
||||
#if UINT_MAX == 65535
|
||||
typedef unsigned int png_uint_16;
|
||||
#elif USHRT_MAX == 65535
|
||||
typedef unsigned short png_uint_16;
|
||||
#else
|
||||
# error "libpng requires an unsigned 16 bit type"
|
||||
#endif
|
||||
|
||||
#if INT_MIN < -2147483646 && INT_MAX > 2147483646
|
||||
typedef int png_int_32;
|
||||
#elif LONG_MIN < -2147483646 && LONG_MAX > 2147483646
|
||||
typedef long int png_int_32;
|
||||
#else
|
||||
# error "libpng requires a signed 32 bit (or more) type"
|
||||
#endif
|
||||
|
||||
#if UINT_MAX > 4294967294
|
||||
typedef unsigned int png_uint_32;
|
||||
#elif ULONG_MAX > 4294967294
|
||||
typedef unsigned long int png_uint_32;
|
||||
#else
|
||||
# error "libpng requires an unsigned 32 bit (or more) type"
|
||||
#endif
|
||||
|
||||
/* Prior to 1.6.0 it was possible to disable the use of size_t, 1.6.0, however,
|
||||
* requires an ISOC90 compiler and relies on consistent behavior of sizeof.
|
||||
*/
|
||||
typedef size_t png_size_t;
|
||||
#endif
|
||||
#define png_sizeof(x) (sizeof (x))
|
||||
typedef ptrdiff_t png_ptrdiff_t;
|
||||
|
||||
/* The following is needed for medium model support. It cannot be in the
|
||||
* pngpriv.h header. Needs modification for other compilers besides
|
||||
* MSC. Model independent support declares all arrays and pointers to be
|
||||
* large using the far keyword. The zlib version used must also support
|
||||
* model independent data. As of version zlib 1.0.4, the necessary changes
|
||||
* have been made in zlib. The USE_FAR_KEYWORD define triggers other
|
||||
* changes that are needed. (Tim Wegner)
|
||||
/* libpng needs to know the maximum value of 'size_t' and this controls the
|
||||
* definition of png_alloc_size_t, below. This maximum value of size_t limits
|
||||
* but does not control the maximum allocations the library makes - there is
|
||||
* direct application control of this through png_set_user_limits().
|
||||
*/
|
||||
|
||||
/* Separate compiler dependencies (problem here is that zlib.h always
|
||||
* defines FAR. (SJT)
|
||||
*/
|
||||
#ifdef __BORLANDC__
|
||||
# if defined(__LARGE__) || defined(__HUGE__) || defined(__COMPACT__)
|
||||
# define LDATA 1
|
||||
# else
|
||||
# define LDATA 0
|
||||
# endif
|
||||
/* GRR: why is Cygwin in here? Cygwin is not Borland C... */
|
||||
# if !defined(__WIN32__) && !defined(__FLAT__) && !defined(__CYGWIN__)
|
||||
# define PNG_MAX_MALLOC_64K /* only used in build */
|
||||
# if (LDATA != 1)
|
||||
# ifndef FAR
|
||||
# define FAR __far
|
||||
# endif
|
||||
# define USE_FAR_KEYWORD
|
||||
# endif /* LDATA != 1 */
|
||||
/* Possibly useful for moving data out of default segment.
|
||||
* Uncomment it if you want. Could also define FARDATA as
|
||||
* const if your compiler supports it. (SJT)
|
||||
# define FARDATA FAR
|
||||
*/
|
||||
# endif /* __WIN32__, __FLAT__, __CYGWIN__ */
|
||||
#endif /* __BORLANDC__ */
|
||||
|
||||
|
||||
/* Suggest testing for specific compiler first before testing for
|
||||
* FAR. The Watcom compiler defines both __MEDIUM__ and M_I86MM,
|
||||
* making reliance oncertain keywords suspect. (SJT)
|
||||
*/
|
||||
|
||||
/* MSC Medium model */
|
||||
#ifdef FAR
|
||||
# ifdef M_I86MM
|
||||
# define USE_FAR_KEYWORD
|
||||
# define FARDATA FAR
|
||||
# include <dos.h>
|
||||
#ifndef PNG_SMALL_SIZE_T
|
||||
/* Compiler specific tests for systems where size_t is known to be less than
|
||||
* 32 bits (some of these systems may no longer work because of the lack of
|
||||
* 'far' support; see above.)
|
||||
*/
|
||||
# if (defined(__TURBOC__) && !defined(__FLAT__)) ||\
|
||||
(defined(_MSC_VER) && defined(MAXSEG_64K))
|
||||
# define PNG_SMALL_SIZE_T
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* SJT: default case */
|
||||
#ifndef FAR
|
||||
# define FAR
|
||||
/* png_alloc_size_t is guaranteed to be no smaller than png_size_t, and no
|
||||
* smaller than png_uint_32. Casts from png_size_t or png_uint_32 to
|
||||
* png_alloc_size_t are not necessary; in fact, it is recommended not to use
|
||||
* them at all so that the compiler can complain when something turns out to be
|
||||
* problematic.
|
||||
*
|
||||
* Casts in the other direction (from png_alloc_size_t to png_size_t or
|
||||
* png_uint_32) should be explicitly applied; however, we do not expect to
|
||||
* encounter practical situations that require such conversions.
|
||||
*
|
||||
* PNG_SMALL_SIZE_T must be defined if the maximum value of size_t is less than
|
||||
* 4294967295 - i.e. less than the maximum value of png_uint_32.
|
||||
*/
|
||||
#ifdef PNG_SMALL_SIZE_T
|
||||
typedef png_uint_32 png_alloc_size_t;
|
||||
#else
|
||||
typedef png_size_t png_alloc_size_t;
|
||||
#endif
|
||||
|
||||
/* At this point FAR is always defined */
|
||||
#ifndef FARDATA
|
||||
# define FARDATA
|
||||
#endif
|
||||
/* Prior to 1.6.0 libpng offered limited support for Microsoft C compiler
|
||||
* implementations of Intel CPU specific support of user-mode segmented address
|
||||
* spaces, where 16-bit pointers address more than 65536 bytes of memory using
|
||||
* separate 'segment' registers. The implementation requires two different
|
||||
* types of pointer (only one of which includes the segment value.)
|
||||
*
|
||||
* If required this support is available in version 1.2 of libpng and may be
|
||||
* available in versions through 1.5, although the correctness of the code has
|
||||
* not been verified recently.
|
||||
*/
|
||||
|
||||
/* Typedef for floating-point numbers that are converted
|
||||
* to fixed-point with a multiple of 100,000, e.g., gamma
|
||||
/* Typedef for floating-point numbers that are converted to fixed-point with a
|
||||
* multiple of 100,000, e.g., gamma
|
||||
*/
|
||||
typedef png_int_32 png_fixed_point;
|
||||
|
||||
/* Add typedefs for pointers */
|
||||
typedef void FAR * png_voidp;
|
||||
typedef PNG_CONST void FAR * png_const_voidp;
|
||||
typedef png_byte FAR * png_bytep;
|
||||
typedef PNG_CONST png_byte FAR * png_const_bytep;
|
||||
typedef png_uint_32 FAR * png_uint_32p;
|
||||
typedef PNG_CONST png_uint_32 FAR * png_const_uint_32p;
|
||||
typedef png_int_32 FAR * png_int_32p;
|
||||
typedef PNG_CONST png_int_32 FAR * png_const_int_32p;
|
||||
typedef png_uint_16 FAR * png_uint_16p;
|
||||
typedef PNG_CONST png_uint_16 FAR * png_const_uint_16p;
|
||||
typedef png_int_16 FAR * png_int_16p;
|
||||
typedef PNG_CONST png_int_16 FAR * png_const_int_16p;
|
||||
typedef char FAR * png_charp;
|
||||
typedef PNG_CONST char FAR * png_const_charp;
|
||||
typedef png_fixed_point FAR * png_fixed_point_p;
|
||||
typedef PNG_CONST png_fixed_point FAR * png_const_fixed_point_p;
|
||||
typedef png_size_t FAR * png_size_tp;
|
||||
typedef PNG_CONST png_size_t FAR * png_const_size_tp;
|
||||
typedef void * png_voidp;
|
||||
typedef const void * png_const_voidp;
|
||||
typedef png_byte * png_bytep;
|
||||
typedef const png_byte * png_const_bytep;
|
||||
typedef png_uint_32 * png_uint_32p;
|
||||
typedef const png_uint_32 * png_const_uint_32p;
|
||||
typedef png_int_32 * png_int_32p;
|
||||
typedef const png_int_32 * png_const_int_32p;
|
||||
typedef png_uint_16 * png_uint_16p;
|
||||
typedef const png_uint_16 * png_const_uint_16p;
|
||||
typedef png_int_16 * png_int_16p;
|
||||
typedef const png_int_16 * png_const_int_16p;
|
||||
typedef char * png_charp;
|
||||
typedef const char * png_const_charp;
|
||||
typedef png_fixed_point * png_fixed_point_p;
|
||||
typedef const png_fixed_point * png_const_fixed_point_p;
|
||||
typedef png_size_t * png_size_tp;
|
||||
typedef const png_size_t * png_const_size_tp;
|
||||
|
||||
#ifdef PNG_STDIO_SUPPORTED
|
||||
typedef FILE * png_FILE_p;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
typedef double FAR * png_doublep;
|
||||
typedef PNG_CONST double FAR * png_const_doublep;
|
||||
typedef double * png_doublep;
|
||||
typedef const double * png_const_doublep;
|
||||
#endif
|
||||
|
||||
/* Pointers to pointers; i.e. arrays */
|
||||
typedef png_byte FAR * FAR * png_bytepp;
|
||||
typedef png_uint_32 FAR * FAR * png_uint_32pp;
|
||||
typedef png_int_32 FAR * FAR * png_int_32pp;
|
||||
typedef png_uint_16 FAR * FAR * png_uint_16pp;
|
||||
typedef png_int_16 FAR * FAR * png_int_16pp;
|
||||
typedef PNG_CONST char FAR * FAR * png_const_charpp;
|
||||
typedef char FAR * FAR * png_charpp;
|
||||
typedef png_fixed_point FAR * FAR * png_fixed_point_pp;
|
||||
typedef png_byte * * png_bytepp;
|
||||
typedef png_uint_32 * * png_uint_32pp;
|
||||
typedef png_int_32 * * png_int_32pp;
|
||||
typedef png_uint_16 * * png_uint_16pp;
|
||||
typedef png_int_16 * * png_int_16pp;
|
||||
typedef const char * * png_const_charpp;
|
||||
typedef char * * png_charpp;
|
||||
typedef png_fixed_point * * png_fixed_point_pp;
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
typedef double FAR * FAR * png_doublepp;
|
||||
typedef double * * png_doublepp;
|
||||
#endif
|
||||
|
||||
/* Pointers to pointers to pointers; i.e., pointer to array */
|
||||
typedef char FAR * FAR * FAR * png_charppp;
|
||||
typedef char * * * png_charppp;
|
||||
|
||||
/* png_alloc_size_t is guaranteed to be no smaller than png_size_t,
|
||||
* and no smaller than png_uint_32. Casts from png_size_t or png_uint_32
|
||||
* to png_alloc_size_t are not necessary; in fact, it is recommended
|
||||
* not to use them at all so that the compiler can complain when something
|
||||
* turns out to be problematic.
|
||||
* Casts in the other direction (from png_alloc_size_t to png_size_t or
|
||||
* png_uint_32) should be explicitly applied; however, we do not expect
|
||||
* to encounter practical situations that require such conversions.
|
||||
*/
|
||||
#if defined(__TURBOC__) && !defined(__FLAT__)
|
||||
typedef unsigned long png_alloc_size_t;
|
||||
#else
|
||||
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
||||
typedef unsigned long png_alloc_size_t;
|
||||
# else
|
||||
/* This is an attempt to detect an old Windows system where (int) is
|
||||
* actually 16 bits, in that case png_malloc must have an argument with a
|
||||
* bigger size to accommodate the requirements of the library.
|
||||
*/
|
||||
# if (defined(_Windows) || defined(_WINDOWS) || defined(_WINDOWS_)) && \
|
||||
(!defined(INT_MAX) || INT_MAX <= 0x7ffffffeL)
|
||||
typedef DWORD png_alloc_size_t;
|
||||
# else
|
||||
typedef png_size_t png_alloc_size_t;
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
#endif /* PNG_BUILDING_SYMBOL_TABLE */
|
||||
|
||||
#endif /* PNGCONF_H */
|
||||
|
@ -29,11 +29,11 @@
|
||||
* However, the following notice accompanied the original version of this
|
||||
* file and, per its terms, should not be removed:
|
||||
*
|
||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
* Last changed in libpng 1.5.0 [January 6, 2011]
|
||||
* Last changed in libpng 1.6.8 [December 19, 2013]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@ -53,7 +53,7 @@
|
||||
* (actually ((void)0)).
|
||||
*
|
||||
* level: level of detail of message, starting at 0. A level 'n'
|
||||
* message is preceded by 'n' tab characters (not implemented
|
||||
* message is preceded by 'n' 3-space indentations (not implemented
|
||||
* on Microsoft compilers unless PNG_DEBUG_FILE is also
|
||||
* defined, to allow debug DLL compilation with no standard IO).
|
||||
* message: a printf(3) style text string. A trailing '\n' is added
|
||||
@ -105,32 +105,29 @@
|
||||
# endif /* PNG_DEBUG_FILE */
|
||||
|
||||
# if (PNG_DEBUG > 1)
|
||||
/* Note: ["%s"m PNG_STRING_NEWLINE] probably does not work on
|
||||
* non-ISO compilers
|
||||
*/
|
||||
# ifdef __STDC__
|
||||
# ifndef png_debug
|
||||
# define png_debug(l,m) \
|
||||
do { \
|
||||
int num_tabs=l; \
|
||||
fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \
|
||||
(num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":"")))); \
|
||||
fprintf(PNG_DEBUG_FILE,"%s" m PNG_STRING_NEWLINE,(num_tabs==1 ? " " : \
|
||||
(num_tabs==2 ? " " : (num_tabs>2 ? " " : "")))); \
|
||||
} while (0)
|
||||
# endif
|
||||
# ifndef png_debug1
|
||||
# define png_debug1(l,m,p1) \
|
||||
do { \
|
||||
int num_tabs=l; \
|
||||
fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \
|
||||
(num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1); \
|
||||
fprintf(PNG_DEBUG_FILE,"%s" m PNG_STRING_NEWLINE,(num_tabs==1 ? " " : \
|
||||
(num_tabs==2 ? " " : (num_tabs>2 ? " " : ""))),p1); \
|
||||
} while (0)
|
||||
# endif
|
||||
# ifndef png_debug2
|
||||
# define png_debug2(l,m,p1,p2) \
|
||||
do { \
|
||||
int num_tabs=l; \
|
||||
fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \
|
||||
(num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1,p2); \
|
||||
fprintf(PNG_DEBUG_FILE,"%s" m PNG_STRING_NEWLINE,(num_tabs==1 ? " " : \
|
||||
(num_tabs==2 ? " " : (num_tabs>2 ? " " : ""))),p1,p2);\
|
||||
} while (0)
|
||||
# endif
|
||||
# else /* __STDC __ */
|
||||
|
@ -29,8 +29,8 @@
|
||||
* However, the following notice accompanied the original version of this
|
||||
* file and, per its terms, should not be removed:
|
||||
*
|
||||
* Last changed in libpng 1.5.4 [July 7, 2011]
|
||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.15 [November 20, 2014]
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@ -48,14 +48,14 @@
|
||||
|
||||
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
||||
|
||||
static PNG_FUNCTION(void, png_default_error,PNGARG((png_structp png_ptr,
|
||||
static PNG_FUNCTION(void, png_default_error,PNGARG((png_const_structrp png_ptr,
|
||||
png_const_charp error_message)),PNG_NORETURN);
|
||||
|
||||
#ifdef PNG_WARNINGS_SUPPORTED
|
||||
static void /* PRIVATE */
|
||||
png_default_warning PNGARG((png_structp png_ptr,
|
||||
png_default_warning PNGARG((png_const_structrp png_ptr,
|
||||
png_const_charp warning_message));
|
||||
#endif /* PNG_WARNINGS_SUPPORTED */
|
||||
#endif /* WARNINGS */
|
||||
|
||||
/* This function is called whenever there is a fatal error. This function
|
||||
* should not be changed. If there is a need to handle errors differently,
|
||||
@ -64,14 +64,15 @@ png_default_warning PNGARG((png_structp png_ptr,
|
||||
*/
|
||||
#ifdef PNG_ERROR_TEXT_SUPPORTED
|
||||
PNG_FUNCTION(void,PNGAPI
|
||||
png_error,(png_structp png_ptr, png_const_charp error_message),PNG_NORETURN)
|
||||
png_error,(png_const_structrp png_ptr, png_const_charp error_message),
|
||||
PNG_NORETURN)
|
||||
{
|
||||
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
||||
char msg[16];
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
if (png_ptr->flags&
|
||||
(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))
|
||||
if ((png_ptr->flags &
|
||||
(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) != 0
|
||||
{
|
||||
if (*error_message == PNG_LITERAL_SHARP)
|
||||
{
|
||||
@ -81,7 +82,7 @@ png_error,(png_structp png_ptr, png_const_charp error_message),PNG_NORETURN)
|
||||
if (error_message[offset] == ' ')
|
||||
break;
|
||||
|
||||
if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT)
|
||||
if ((png_ptr->flags & PNG_FLAG_STRIP_ERROR_TEXT) != 0)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < offset - 1; i++)
|
||||
@ -96,7 +97,7 @@ png_error,(png_structp png_ptr, png_const_charp error_message),PNG_NORETURN)
|
||||
|
||||
else
|
||||
{
|
||||
if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT)
|
||||
if ((png_ptr->flags & PNG_FLAG_STRIP_ERROR_TEXT) != 0)
|
||||
{
|
||||
msg[0] = '0';
|
||||
msg[1] = '\0';
|
||||
@ -107,7 +108,8 @@ png_error,(png_structp png_ptr, png_const_charp error_message),PNG_NORETURN)
|
||||
}
|
||||
#endif
|
||||
if (png_ptr != NULL && png_ptr->error_fn != NULL)
|
||||
(*(png_ptr->error_fn))(png_ptr, error_message);
|
||||
(*(png_ptr->error_fn))(png_constcast(png_structrp,png_ptr),
|
||||
error_message);
|
||||
|
||||
/* If the custom handler doesn't exist, or if it returns,
|
||||
use the default handler, which will not return. */
|
||||
@ -115,7 +117,7 @@ png_error,(png_structp png_ptr, png_const_charp error_message),PNG_NORETURN)
|
||||
}
|
||||
#else
|
||||
PNG_FUNCTION(void,PNGAPI
|
||||
png_err,(png_structp png_ptr),PNG_NORETURN)
|
||||
png_err,(png_const_structrp png_ptr),PNG_NORETURN)
|
||||
{
|
||||
/* Prior to 1.5.2 the error_fn received a NULL pointer, expressed
|
||||
* erroneously as '\0', instead of the empty string "". This was
|
||||
@ -123,13 +125,13 @@ png_err,(png_structp png_ptr),PNG_NORETURN)
|
||||
* will crash in this case.
|
||||
*/
|
||||
if (png_ptr != NULL && png_ptr->error_fn != NULL)
|
||||
(*(png_ptr->error_fn))(png_ptr, "");
|
||||
(*(png_ptr->error_fn))(png_constcast(png_structrp,png_ptr), "");
|
||||
|
||||
/* If the custom handler doesn't exist, or if it returns,
|
||||
use the default handler, which will not return. */
|
||||
png_default_error(png_ptr, "");
|
||||
}
|
||||
#endif /* PNG_ERROR_TEXT_SUPPORTED */
|
||||
#endif /* ERROR_TEXT */
|
||||
|
||||
/* Utility to safely appends strings to a buffer. This never errors out so
|
||||
* error checking is not required in the caller.
|
||||
@ -178,7 +180,7 @@ png_format_number(png_const_charp start, png_charp end, int format,
|
||||
case PNG_NUMBER_FORMAT_fixed:
|
||||
/* Needs five digits (the fraction) */
|
||||
mincount = 5;
|
||||
if (output || number % 10 != 0)
|
||||
if (output != 0 || number % 10 != 0)
|
||||
{
|
||||
*--end = digits[number % 10];
|
||||
output = 1;
|
||||
@ -189,7 +191,7 @@ png_format_number(png_const_charp start, png_charp end, int format,
|
||||
case PNG_NUMBER_FORMAT_02u:
|
||||
/* Expects at least 2 digits. */
|
||||
mincount = 2;
|
||||
/* fall through */
|
||||
/* FALL THROUGH */
|
||||
|
||||
case PNG_NUMBER_FORMAT_u:
|
||||
*--end = digits[number % 10];
|
||||
@ -199,7 +201,7 @@ png_format_number(png_const_charp start, png_charp end, int format,
|
||||
case PNG_NUMBER_FORMAT_02x:
|
||||
/* This format expects at least two digits */
|
||||
mincount = 2;
|
||||
/* fall through */
|
||||
/* FALL THROUGH */
|
||||
|
||||
case PNG_NUMBER_FORMAT_x:
|
||||
*--end = digits[number & 0xf];
|
||||
@ -215,13 +217,13 @@ png_format_number(png_const_charp start, png_charp end, int format,
|
||||
++count;
|
||||
|
||||
/* Float a fixed number here: */
|
||||
if (format == PNG_NUMBER_FORMAT_fixed) if (count == 5) if (end > start)
|
||||
if ((format == PNG_NUMBER_FORMAT_fixed) && (count == 5) && (end > start))
|
||||
{
|
||||
/* End of the fraction, but maybe nothing was output? In that case
|
||||
* drop the decimal point. If the number is a true zero handle that
|
||||
* here.
|
||||
*/
|
||||
if (output)
|
||||
if (output != 0)
|
||||
*--end = '.';
|
||||
else if (number == 0) /* and !output */
|
||||
*--end = '0';
|
||||
@ -239,14 +241,14 @@ png_format_number(png_const_charp start, png_charp end, int format,
|
||||
* png_set_error_fn() to replace the warning function at run-time.
|
||||
*/
|
||||
void PNGAPI
|
||||
png_warning(png_structp png_ptr, png_const_charp warning_message)
|
||||
png_warning(png_const_structrp png_ptr, png_const_charp warning_message)
|
||||
{
|
||||
int offset = 0;
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
||||
if (png_ptr->flags&
|
||||
(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))
|
||||
if ((png_ptr->flags &
|
||||
(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) != 0)
|
||||
#endif
|
||||
{
|
||||
if (*warning_message == PNG_LITERAL_SHARP)
|
||||
@ -258,7 +260,8 @@ png_warning(png_structp png_ptr, png_const_charp warning_message)
|
||||
}
|
||||
}
|
||||
if (png_ptr != NULL && png_ptr->warning_fn != NULL)
|
||||
(*(png_ptr->warning_fn))(png_ptr, warning_message + offset);
|
||||
(*(png_ptr->warning_fn))(png_constcast(png_structrp,png_ptr),
|
||||
warning_message + offset);
|
||||
else
|
||||
png_default_warning(png_ptr, warning_message + offset);
|
||||
}
|
||||
@ -306,38 +309,43 @@ png_warning_parameter_signed(png_warning_parameters p, int number, int format,
|
||||
}
|
||||
|
||||
void
|
||||
png_formatted_warning(png_structp png_ptr, png_warning_parameters p,
|
||||
png_formatted_warning(png_const_structrp png_ptr, png_warning_parameters p,
|
||||
png_const_charp message)
|
||||
{
|
||||
/* The internal buffer is just 128 bytes - enough for all our messages,
|
||||
* overflow doesn't happen because this code checks!
|
||||
/* The internal buffer is just 192 bytes - enough for all our messages,
|
||||
* overflow doesn't happen because this code checks! If someone figures
|
||||
* out how to send us a message longer than 192 bytes, all that will
|
||||
* happen is that the message will be truncated appropriately.
|
||||
*/
|
||||
size_t i;
|
||||
char msg[128];
|
||||
size_t i = 0; /* Index in the msg[] buffer: */
|
||||
char msg[192];
|
||||
|
||||
for (i=0; i<(sizeof msg)-1 && *message != '\0'; ++i)
|
||||
/* Each iteration through the following loop writes at most one character
|
||||
* to msg[i++] then returns here to validate that there is still space for
|
||||
* the trailing '\0'. It may (in the case of a parameter) read more than
|
||||
* one character from message[]; it must check for '\0' and continue to the
|
||||
* test if it finds the end of string.
|
||||
*/
|
||||
while (i<(sizeof msg)-1 && *message != '\0')
|
||||
{
|
||||
if (*message == '@')
|
||||
/* '@' at end of string is now just printed (previously it was skipped);
|
||||
* it is an error in the calling code to terminate the string with @.
|
||||
*/
|
||||
if (p != NULL && *message == '@' && message[1] != '\0')
|
||||
{
|
||||
int parameter = -1;
|
||||
switch (*++message)
|
||||
{
|
||||
case '1':
|
||||
parameter = 0;
|
||||
break;
|
||||
int parameter_char = *++message; /* Consume the '@' */
|
||||
static const char valid_parameters[] = "123456789";
|
||||
int parameter = 0;
|
||||
|
||||
case '2':
|
||||
parameter = 1;
|
||||
break;
|
||||
/* Search for the parameter digit, the index in the string is the
|
||||
* parameter to use.
|
||||
*/
|
||||
while (valid_parameters[parameter] != parameter_char &&
|
||||
valid_parameters[parameter] != '\0')
|
||||
++parameter;
|
||||
|
||||
case '\0':
|
||||
continue; /* To break out of the for loop above. */
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (parameter >= 0 && parameter < PNG_WARNING_PARAMETER_COUNT)
|
||||
/* If the parameter digit is out of range it will just get printed. */
|
||||
if (parameter < PNG_WARNING_PARAMETER_COUNT)
|
||||
{
|
||||
/* Append this parameter */
|
||||
png_const_charp parm = p[parameter];
|
||||
@ -347,47 +355,101 @@ png_formatted_warning(png_structp png_ptr, png_warning_parameters p,
|
||||
* that parm[] has been initialized, so there is no guarantee of a
|
||||
* trailing '\0':
|
||||
*/
|
||||
for (; i<(sizeof msg)-1 && parm != '\0' && parm < pend; ++i)
|
||||
msg[i] = *parm++;
|
||||
while (i<(sizeof msg)-1 && *parm != '\0' && parm < pend)
|
||||
msg[i++] = *parm++;
|
||||
|
||||
/* Consume the parameter digit too: */
|
||||
++message;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* else not a parameter and there is a character after the @ sign; just
|
||||
* copy that.
|
||||
* copy that. This is known not to be '\0' because of the test above.
|
||||
*/
|
||||
}
|
||||
|
||||
/* At this point *message can't be '\0', even in the bad parameter case
|
||||
* above where there is a lone '@' at the end of the message string.
|
||||
*/
|
||||
msg[i] = *message++;
|
||||
msg[i++] = *message++;
|
||||
}
|
||||
|
||||
/* i is always less than (sizeof msg), so: */
|
||||
msg[i] = '\0';
|
||||
|
||||
/* And this is the formatted message: */
|
||||
/* And this is the formatted message. It may be larger than
|
||||
* PNG_MAX_ERROR_TEXT, but that is only used for 'chunk' errors and these
|
||||
* are not (currently) formatted.
|
||||
*/
|
||||
png_warning(png_ptr, msg);
|
||||
}
|
||||
#endif /* PNG_WARNINGS_SUPPORTED */
|
||||
#endif /* WARNINGS */
|
||||
|
||||
#ifdef PNG_BENIGN_ERRORS_SUPPORTED
|
||||
void PNGAPI
|
||||
png_benign_error(png_structp png_ptr, png_const_charp error_message)
|
||||
png_benign_error(png_const_structrp png_ptr, png_const_charp error_message)
|
||||
{
|
||||
if (png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN)
|
||||
if ((png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN) != 0)
|
||||
{
|
||||
# ifdef PNG_READ_SUPPORTED
|
||||
if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0 &&
|
||||
png_ptr->chunk_name != 0)
|
||||
png_chunk_warning(png_ptr, error_message);
|
||||
else
|
||||
# endif
|
||||
png_warning(png_ptr, error_message);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
# ifdef PNG_READ_SUPPORTED
|
||||
if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0 &&
|
||||
png_ptr->chunk_name != 0)
|
||||
png_chunk_error(png_ptr, error_message);
|
||||
else
|
||||
# endif
|
||||
png_error(png_ptr, error_message);
|
||||
}
|
||||
|
||||
# ifndef PNG_ERROR_TEXT_SUPPORTED
|
||||
PNG_UNUSED(error_message)
|
||||
# endif
|
||||
}
|
||||
|
||||
void /* PRIVATE */
|
||||
png_app_warning(png_const_structrp png_ptr, png_const_charp error_message)
|
||||
{
|
||||
if ((png_ptr->flags & PNG_FLAG_APP_WARNINGS_WARN) != 0)
|
||||
png_warning(png_ptr, error_message);
|
||||
else
|
||||
png_error(png_ptr, error_message);
|
||||
}
|
||||
#endif
|
||||
|
||||
# ifndef PNG_ERROR_TEXT_SUPPORTED
|
||||
PNG_UNUSED(error_message)
|
||||
# endif
|
||||
}
|
||||
|
||||
void /* PRIVATE */
|
||||
png_app_error(png_const_structrp png_ptr, png_const_charp error_message)
|
||||
{
|
||||
if ((png_ptr->flags & PNG_FLAG_APP_ERRORS_WARN) != 0)
|
||||
png_warning(png_ptr, error_message);
|
||||
else
|
||||
png_error(png_ptr, error_message);
|
||||
|
||||
# ifndef PNG_ERROR_TEXT_SUPPORTED
|
||||
PNG_UNUSED(error_message)
|
||||
# endif
|
||||
}
|
||||
#endif /* BENIGN_ERRORS */
|
||||
|
||||
#define PNG_MAX_ERROR_TEXT 196 /* Currently limited by profile_error in png.c */
|
||||
#if defined(PNG_WARNINGS_SUPPORTED) || \
|
||||
(defined(PNG_READ_SUPPORTED) && defined(PNG_ERROR_TEXT_SUPPORTED))
|
||||
/* These utilities are used internally to build an error message that relates
|
||||
* to the current chunk. The chunk name comes from png_ptr->chunk_name,
|
||||
* this is used to prefix the message. The message is limited in length
|
||||
* to 63 bytes, the name characters are output as hex digits wrapped in []
|
||||
* which is used to prefix the message. The message is limited in length
|
||||
* to 63 bytes. The name characters are output as hex digits wrapped in []
|
||||
* if the character is invalid.
|
||||
*/
|
||||
#define isnonalpha(c) ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97))
|
||||
@ -396,18 +458,19 @@ static PNG_CONST char png_digit[16] = {
|
||||
'A', 'B', 'C', 'D', 'E', 'F'
|
||||
};
|
||||
|
||||
#define PNG_MAX_ERROR_TEXT 64
|
||||
#if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_ERROR_TEXT_SUPPORTED)
|
||||
static void /* PRIVATE */
|
||||
png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp
|
||||
png_format_buffer(png_const_structrp png_ptr, png_charp buffer, png_const_charp
|
||||
error_message)
|
||||
{
|
||||
int iout = 0, iin = 0;
|
||||
png_uint_32 chunk_name = png_ptr->chunk_name;
|
||||
int iout = 0, ishift = 24;
|
||||
|
||||
while (iin < 4)
|
||||
while (ishift >= 0)
|
||||
{
|
||||
int c = png_ptr->chunk_name[iin++];
|
||||
if (isnonalpha(c))
|
||||
int c = (int)(chunk_name >> ishift) & 0xff;
|
||||
|
||||
ishift -= 8;
|
||||
if (isnonalpha(c) != 0)
|
||||
{
|
||||
buffer[iout++] = PNG_LITERAL_LEFT_SQUARE_BRACKET;
|
||||
buffer[iout++] = png_digit[(c & 0xf0) >> 4];
|
||||
@ -417,7 +480,7 @@ png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp
|
||||
|
||||
else
|
||||
{
|
||||
buffer[iout++] = (png_byte)c;
|
||||
buffer[iout++] = (char)c;
|
||||
}
|
||||
}
|
||||
|
||||
@ -426,10 +489,11 @@ png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp
|
||||
|
||||
else
|
||||
{
|
||||
int iin = 0;
|
||||
|
||||
buffer[iout++] = ':';
|
||||
buffer[iout++] = ' ';
|
||||
|
||||
iin = 0;
|
||||
while (iin < PNG_MAX_ERROR_TEXT-1 && error_message[iin] != '\0')
|
||||
buffer[iout++] = error_message[iin++];
|
||||
|
||||
@ -437,11 +501,11 @@ png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp
|
||||
buffer[iout] = '\0';
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WARNINGS_SUPPORTED || PNG_ERROR_TEXT_SUPPORTED */
|
||||
#endif /* WARNINGS || ERROR_TEXT */
|
||||
|
||||
#if defined(PNG_READ_SUPPORTED) && defined(PNG_ERROR_TEXT_SUPPORTED)
|
||||
PNG_FUNCTION(void,PNGAPI
|
||||
png_chunk_error,(png_structp png_ptr, png_const_charp error_message),
|
||||
png_chunk_error,(png_const_structrp png_ptr, png_const_charp error_message),
|
||||
PNG_NORETURN)
|
||||
{
|
||||
char msg[18+PNG_MAX_ERROR_TEXT];
|
||||
@ -454,11 +518,11 @@ png_chunk_error,(png_structp png_ptr, png_const_charp error_message),
|
||||
png_error(png_ptr, msg);
|
||||
}
|
||||
}
|
||||
#endif /* PNG_READ_SUPPORTED && PNG_ERROR_TEXT_SUPPORTED */
|
||||
#endif /* READ && ERROR_TEXT */
|
||||
|
||||
#ifdef PNG_WARNINGS_SUPPORTED
|
||||
void PNGAPI
|
||||
png_chunk_warning(png_structp png_ptr, png_const_charp warning_message)
|
||||
png_chunk_warning(png_const_structrp png_ptr, png_const_charp warning_message)
|
||||
{
|
||||
char msg[18+PNG_MAX_ERROR_TEXT];
|
||||
if (png_ptr == NULL)
|
||||
@ -470,38 +534,83 @@ png_chunk_warning(png_structp png_ptr, png_const_charp warning_message)
|
||||
png_warning(png_ptr, msg);
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WARNINGS_SUPPORTED */
|
||||
#endif /* WARNINGS */
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
#ifdef PNG_BENIGN_ERRORS_SUPPORTED
|
||||
void PNGAPI
|
||||
png_chunk_benign_error(png_structp png_ptr, png_const_charp error_message)
|
||||
png_chunk_benign_error(png_const_structrp png_ptr, png_const_charp
|
||||
error_message)
|
||||
{
|
||||
if (png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN)
|
||||
if ((png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN) != 0)
|
||||
png_chunk_warning(png_ptr, error_message);
|
||||
|
||||
else
|
||||
png_chunk_error(png_ptr, error_message);
|
||||
|
||||
# ifndef PNG_ERROR_TEXT_SUPPORTED
|
||||
PNG_UNUSED(error_message)
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
#endif /* READ */
|
||||
|
||||
void /* PRIVATE */
|
||||
png_chunk_report(png_const_structrp png_ptr, png_const_charp message, int error)
|
||||
{
|
||||
# ifndef PNG_WARNINGS_SUPPORTED
|
||||
PNG_UNUSED(message)
|
||||
# endif
|
||||
|
||||
/* This is always supported, but for just read or just write it
|
||||
* unconditionally does the right thing.
|
||||
*/
|
||||
# if defined(PNG_READ_SUPPORTED) && defined(PNG_WRITE_SUPPORTED)
|
||||
if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0)
|
||||
# endif
|
||||
|
||||
# ifdef PNG_READ_SUPPORTED
|
||||
{
|
||||
if (error < PNG_CHUNK_ERROR)
|
||||
png_chunk_warning(png_ptr, message);
|
||||
|
||||
else
|
||||
png_chunk_benign_error(png_ptr, message);
|
||||
}
|
||||
# endif
|
||||
|
||||
# if defined(PNG_READ_SUPPORTED) && defined(PNG_WRITE_SUPPORTED)
|
||||
else if ((png_ptr->mode & PNG_IS_READ_STRUCT) == 0)
|
||||
# endif
|
||||
|
||||
# ifdef PNG_WRITE_SUPPORTED
|
||||
{
|
||||
if (error < PNG_CHUNK_WRITE_ERROR)
|
||||
png_app_warning(png_ptr, message);
|
||||
|
||||
else
|
||||
png_app_error(png_ptr, message);
|
||||
}
|
||||
# endif
|
||||
}
|
||||
|
||||
#ifdef PNG_ERROR_TEXT_SUPPORTED
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
PNG_FUNCTION(void,
|
||||
png_fixed_error,(png_structp png_ptr, png_const_charp name),PNG_NORETURN)
|
||||
png_fixed_error,(png_const_structrp png_ptr, png_const_charp name),PNG_NORETURN)
|
||||
{
|
||||
# define fixed_message "fixed point overflow in "
|
||||
# define fixed_message_ln ((sizeof fixed_message)-1)
|
||||
int iin;
|
||||
char msg[fixed_message_ln+PNG_MAX_ERROR_TEXT];
|
||||
png_memcpy(msg, fixed_message, fixed_message_ln);
|
||||
memcpy(msg, fixed_message, fixed_message_ln);
|
||||
iin = 0;
|
||||
if (name != NULL) while (iin < (PNG_MAX_ERROR_TEXT-1) && name[iin] != 0)
|
||||
{
|
||||
msg[fixed_message_ln + iin] = name[iin];
|
||||
++iin;
|
||||
}
|
||||
if (name != NULL)
|
||||
while (iin < (PNG_MAX_ERROR_TEXT-1) && name[iin] != 0)
|
||||
{
|
||||
msg[fixed_message_ln + iin] = name[iin];
|
||||
++iin;
|
||||
}
|
||||
msg[fixed_message_ln + iin] = 0;
|
||||
png_error(png_ptr, msg);
|
||||
}
|
||||
@ -513,14 +622,111 @@ png_fixed_error,(png_structp png_ptr, png_const_charp name),PNG_NORETURN)
|
||||
* otherwise it is necessary for png_default_error to be overridden.
|
||||
*/
|
||||
jmp_buf* PNGAPI
|
||||
png_set_longjmp_fn(png_structp png_ptr, png_longjmp_ptr longjmp_fn,
|
||||
png_set_longjmp_fn(png_structrp png_ptr, png_longjmp_ptr longjmp_fn,
|
||||
size_t jmp_buf_size)
|
||||
{
|
||||
if (png_ptr == NULL || jmp_buf_size != png_sizeof(jmp_buf))
|
||||
/* From libpng 1.6.0 the app gets one chance to set a 'jmpbuf_size' value
|
||||
* and it must not change after that. Libpng doesn't care how big the
|
||||
* buffer is, just that it doesn't change.
|
||||
*
|
||||
* If the buffer size is no *larger* than the size of jmp_buf when libpng is
|
||||
* compiled a built in jmp_buf is returned; this preserves the pre-1.6.0
|
||||
* semantics that this call will not fail. If the size is larger, however,
|
||||
* the buffer is allocated and this may fail, causing the function to return
|
||||
* NULL.
|
||||
*/
|
||||
if (png_ptr == NULL)
|
||||
return NULL;
|
||||
|
||||
if (png_ptr->jmp_buf_ptr == NULL)
|
||||
{
|
||||
png_ptr->jmp_buf_size = 0; /* not allocated */
|
||||
|
||||
if (jmp_buf_size <= (sizeof png_ptr->jmp_buf_local))
|
||||
png_ptr->jmp_buf_ptr = &png_ptr->jmp_buf_local;
|
||||
|
||||
else
|
||||
{
|
||||
png_ptr->jmp_buf_ptr = png_voidcast(jmp_buf *,
|
||||
png_malloc_warn(png_ptr, jmp_buf_size));
|
||||
|
||||
if (png_ptr->jmp_buf_ptr == NULL)
|
||||
return NULL; /* new NULL return on OOM */
|
||||
|
||||
png_ptr->jmp_buf_size = jmp_buf_size;
|
||||
}
|
||||
}
|
||||
|
||||
else /* Already allocated: check the size */
|
||||
{
|
||||
size_t size = png_ptr->jmp_buf_size;
|
||||
|
||||
if (size == 0)
|
||||
{
|
||||
size = (sizeof png_ptr->jmp_buf_local);
|
||||
if (png_ptr->jmp_buf_ptr != &png_ptr->jmp_buf_local)
|
||||
{
|
||||
/* This is an internal error in libpng: somehow we have been left
|
||||
* with a stack allocated jmp_buf when the application regained
|
||||
* control. It's always possible to fix this up, but for the moment
|
||||
* this is a png_error because that makes it easy to detect.
|
||||
*/
|
||||
png_error(png_ptr, "Libpng jmp_buf still allocated");
|
||||
/* png_ptr->jmp_buf_ptr = &png_ptr->jmp_buf_local; */
|
||||
}
|
||||
}
|
||||
|
||||
if (size != jmp_buf_size)
|
||||
{
|
||||
png_warning(png_ptr, "Application jmp_buf size changed");
|
||||
return NULL; /* caller will probably crash: no choice here */
|
||||
}
|
||||
}
|
||||
|
||||
/* Finally fill in the function, now we have a satisfactory buffer. It is
|
||||
* valid to change the function on every call.
|
||||
*/
|
||||
png_ptr->longjmp_fn = longjmp_fn;
|
||||
return &png_ptr->longjmp_buffer;
|
||||
return png_ptr->jmp_buf_ptr;
|
||||
}
|
||||
|
||||
void /* PRIVATE */
|
||||
png_free_jmpbuf(png_structrp png_ptr)
|
||||
{
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
jmp_buf *jb = png_ptr->jmp_buf_ptr;
|
||||
|
||||
/* A size of 0 is used to indicate a local, stack, allocation of the
|
||||
* pointer; used here and in png.c
|
||||
*/
|
||||
if (jb != NULL && png_ptr->jmp_buf_size > 0)
|
||||
{
|
||||
|
||||
/* This stuff is so that a failure to free the error control structure
|
||||
* does not leave libpng in a state with no valid error handling: the
|
||||
* free always succeeds, if there is an error it gets ignored.
|
||||
*/
|
||||
if (jb != &png_ptr->jmp_buf_local)
|
||||
{
|
||||
/* Make an internal, libpng, jmp_buf to return here */
|
||||
jmp_buf free_jmp_buf;
|
||||
|
||||
if (!setjmp(free_jmp_buf))
|
||||
{
|
||||
png_ptr->jmp_buf_ptr = &free_jmp_buf; /* come back here */
|
||||
png_ptr->jmp_buf_size = 0; /* stack allocation */
|
||||
png_ptr->longjmp_fn = longjmp;
|
||||
png_free(png_ptr, jb); /* Return to setjmp on error */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* *Always* cancel everything out: */
|
||||
png_ptr->jmp_buf_size = 0;
|
||||
png_ptr->jmp_buf_ptr = NULL;
|
||||
png_ptr->longjmp_fn = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -530,7 +736,7 @@ png_set_longjmp_fn(png_structp png_ptr, png_longjmp_ptr longjmp_fn,
|
||||
* error function pointer in png_set_error_fn().
|
||||
*/
|
||||
static PNG_FUNCTION(void /* PRIVATE */,
|
||||
png_default_error,(png_structp png_ptr, png_const_charp error_message),
|
||||
png_default_error,(png_const_structrp png_ptr, png_const_charp error_message),
|
||||
PNG_NORETURN)
|
||||
{
|
||||
#ifdef PNG_CONSOLE_IO_SUPPORTED
|
||||
@ -577,24 +783,23 @@ png_default_error,(png_structp png_ptr, png_const_charp error_message),
|
||||
}
|
||||
|
||||
PNG_FUNCTION(void,PNGAPI
|
||||
png_longjmp,(png_structp png_ptr, int val),PNG_NORETURN)
|
||||
png_longjmp,(png_const_structrp png_ptr, int val),PNG_NORETURN)
|
||||
{
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
if (png_ptr && png_ptr->longjmp_fn)
|
||||
{
|
||||
# ifdef USE_FAR_KEYWORD
|
||||
{
|
||||
jmp_buf tmp_jmpbuf;
|
||||
png_memcpy(tmp_jmpbuf, png_ptr->longjmp_buffer, png_sizeof(jmp_buf));
|
||||
png_ptr->longjmp_fn(tmp_jmpbuf, val);
|
||||
}
|
||||
|
||||
# else
|
||||
png_ptr->longjmp_fn(png_ptr->longjmp_buffer, val);
|
||||
# endif
|
||||
}
|
||||
if (png_ptr != NULL && png_ptr->longjmp_fn != NULL &&
|
||||
png_ptr->jmp_buf_ptr != NULL)
|
||||
png_ptr->longjmp_fn(*png_ptr->jmp_buf_ptr, val);
|
||||
#else
|
||||
PNG_UNUSED(png_ptr)
|
||||
PNG_UNUSED(val)
|
||||
#endif
|
||||
/* Here if not setjmp support or if png_ptr is null. */
|
||||
|
||||
/* If control reaches this point, png_longjmp() must not return. The only
|
||||
* choice is to terminate the whole process (or maybe the thread); to do
|
||||
* this the ANSI-C abort() function is used unless a different method is
|
||||
* implemented by overriding the default configuration setting for
|
||||
* PNG_ABORT().
|
||||
*/
|
||||
PNG_ABORT();
|
||||
}
|
||||
|
||||
@ -605,7 +810,7 @@ png_longjmp,(png_structp png_ptr, int val),PNG_NORETURN)
|
||||
* not used, but it is passed in case it may be useful.
|
||||
*/
|
||||
static void /* PRIVATE */
|
||||
png_default_warning(png_structp png_ptr, png_const_charp warning_message)
|
||||
png_default_warning(png_const_structrp png_ptr, png_const_charp warning_message)
|
||||
{
|
||||
#ifdef PNG_CONSOLE_IO_SUPPORTED
|
||||
# ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
||||
@ -647,15 +852,15 @@ png_default_warning(png_structp png_ptr, png_const_charp warning_message)
|
||||
#endif
|
||||
PNG_UNUSED(png_ptr) /* Make compiler happy */
|
||||
}
|
||||
#endif /* PNG_WARNINGS_SUPPORTED */
|
||||
#endif /* WARNINGS */
|
||||
|
||||
/* This function is called when the application wants to use another method
|
||||
* of handling errors and warnings. Note that the error function MUST NOT
|
||||
* return to the calling routine or serious problems will occur. The return
|
||||
* method used in the default routine calls longjmp(png_ptr->longjmp_buffer, 1)
|
||||
* method used in the default routine calls longjmp(png_ptr->jmp_buf_ptr, 1)
|
||||
*/
|
||||
void PNGAPI
|
||||
png_set_error_fn(png_structp png_ptr, png_voidp error_ptr,
|
||||
png_set_error_fn(png_structrp png_ptr, png_voidp error_ptr,
|
||||
png_error_ptr error_fn, png_error_ptr warning_fn)
|
||||
{
|
||||
if (png_ptr == NULL)
|
||||
@ -676,7 +881,7 @@ png_set_error_fn(png_structp png_ptr, png_voidp error_ptr,
|
||||
* pointer before png_write_destroy and png_read_destroy are called.
|
||||
*/
|
||||
png_voidp PNGAPI
|
||||
png_get_error_ptr(png_const_structp png_ptr)
|
||||
png_get_error_ptr(png_const_structrp png_ptr)
|
||||
{
|
||||
if (png_ptr == NULL)
|
||||
return NULL;
|
||||
@ -687,7 +892,7 @@ png_get_error_ptr(png_const_structp png_ptr)
|
||||
|
||||
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_strip_error_numbers(png_structp png_ptr, png_uint_32 strip_mode)
|
||||
png_set_strip_error_numbers(png_structrp png_ptr, png_uint_32 strip_mode)
|
||||
{
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
@ -697,4 +902,90 @@ png_set_strip_error_numbers(png_structp png_ptr, png_uint_32 strip_mode)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
||||
|
||||
#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\
|
||||
defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)
|
||||
/* Currently the above both depend on SETJMP_SUPPORTED, however it would be
|
||||
* possible to implement without setjmp support just so long as there is some
|
||||
* way to handle the error return here:
|
||||
*/
|
||||
PNG_FUNCTION(void /* PRIVATE */, (PNGCBAPI
|
||||
png_safe_error),(png_structp png_nonconst_ptr, png_const_charp error_message),
|
||||
PNG_NORETURN)
|
||||
{
|
||||
const png_const_structrp png_ptr = png_nonconst_ptr;
|
||||
png_imagep image = png_voidcast(png_imagep, png_ptr->error_ptr);
|
||||
|
||||
/* An error is always logged here, overwriting anything (typically a warning)
|
||||
* that is already there:
|
||||
*/
|
||||
if (image != NULL)
|
||||
{
|
||||
png_safecat(image->message, (sizeof image->message), 0, error_message);
|
||||
image->warning_or_error |= PNG_IMAGE_ERROR;
|
||||
|
||||
/* Retrieve the jmp_buf from within the png_control, making this work for
|
||||
* C++ compilation too is pretty tricky: C++ wants a pointer to the first
|
||||
* element of a jmp_buf, but C doesn't tell us the type of that.
|
||||
*/
|
||||
if (image->opaque != NULL && image->opaque->error_buf != NULL)
|
||||
longjmp(png_control_jmp_buf(image->opaque), 1);
|
||||
|
||||
/* Missing longjmp buffer, the following is to help debugging: */
|
||||
{
|
||||
size_t pos = png_safecat(image->message, (sizeof image->message), 0,
|
||||
"bad longjmp: ");
|
||||
png_safecat(image->message, (sizeof image->message), pos,
|
||||
error_message);
|
||||
}
|
||||
}
|
||||
|
||||
/* Here on an internal programming error. */
|
||||
abort();
|
||||
}
|
||||
|
||||
#ifdef PNG_WARNINGS_SUPPORTED
|
||||
void /* PRIVATE */ PNGCBAPI
|
||||
png_safe_warning(png_structp png_nonconst_ptr, png_const_charp warning_message)
|
||||
{
|
||||
const png_const_structrp png_ptr = png_nonconst_ptr;
|
||||
png_imagep image = png_voidcast(png_imagep, png_ptr->error_ptr);
|
||||
|
||||
/* A warning is only logged if there is no prior warning or error. */
|
||||
if (image->warning_or_error == 0)
|
||||
{
|
||||
png_safecat(image->message, (sizeof image->message), 0, warning_message);
|
||||
image->warning_or_error |= PNG_IMAGE_WARNING;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
int /* PRIVATE */
|
||||
png_safe_execute(png_imagep image_in, int (*function)(png_voidp), png_voidp arg)
|
||||
{
|
||||
volatile png_imagep image = image_in;
|
||||
volatile int result;
|
||||
volatile png_voidp saved_error_buf;
|
||||
jmp_buf safe_jmpbuf;
|
||||
|
||||
/* Safely execute function(arg) with png_error returning to this function. */
|
||||
saved_error_buf = image->opaque->error_buf;
|
||||
result = setjmp(safe_jmpbuf) == 0;
|
||||
|
||||
if (result != 0)
|
||||
{
|
||||
|
||||
image->opaque->error_buf = safe_jmpbuf;
|
||||
result = function(arg);
|
||||
}
|
||||
|
||||
image->opaque->error_buf = saved_error_buf;
|
||||
|
||||
/* And do the cleanup prior to any failure return. */
|
||||
if (result == 0)
|
||||
png_image_free(image);
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif /* SIMPLIFIED READ || SIMPLIFIED_WRITE */
|
||||
#endif /* READ || WRITE */
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -29,11 +29,11 @@
|
||||
* However, the following notice accompanied the original version of this
|
||||
* file and, per its terms, should not be removed:
|
||||
*
|
||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
* Last changed in libpng 1.5.0 [January 6, 2011]
|
||||
* Last changed in libpng 1.6.1 [March 28, 2013]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@ -83,7 +83,7 @@
|
||||
|
||||
struct png_info_def
|
||||
{
|
||||
/* the following are necessary for every PNG file */
|
||||
/* The following are necessary for every PNG file */
|
||||
png_uint_32 width; /* width of image in pixels (from IHDR) */
|
||||
png_uint_32 height; /* height of image in pixels (from IHDR) */
|
||||
png_uint_32 valid; /* valid chunk data (see PNG_INFO_ below) */
|
||||
@ -98,11 +98,17 @@ struct png_info_def
|
||||
png_byte filter_type; /* must be PNG_FILTER_TYPE_BASE (from IHDR) */
|
||||
png_byte interlace_type; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
|
||||
|
||||
/* The following is informational only on read, and not used on writes. */
|
||||
/* The following are set by png_set_IHDR, called from the application on
|
||||
* write, but the are never actually used by the write code.
|
||||
*/
|
||||
png_byte channels; /* number of data channels per pixel (1, 2, 3, 4) */
|
||||
png_byte pixel_depth; /* number of bits per pixel */
|
||||
png_byte spare_byte; /* to align the data, and for future use */
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
/* This is never set during write */
|
||||
png_byte signature[8]; /* magic bytes read by libpng from start of file */
|
||||
#endif
|
||||
|
||||
/* The rest of the data is optional. If you are reading, check the
|
||||
* valid field to see if the information in these are valid. If you
|
||||
@ -110,18 +116,25 @@ struct png_info_def
|
||||
* and initialize the appropriate fields below.
|
||||
*/
|
||||
|
||||
#if defined(PNG_gAMA_SUPPORTED)
|
||||
/* The gAMA chunk describes the gamma characteristics of the system
|
||||
* on which the image was created, normally in the range [1.0, 2.5].
|
||||
* Data is valid if (valid & PNG_INFO_gAMA) is non-zero.
|
||||
#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)
|
||||
/* png_colorspace only contains 'flags' if neither GAMMA or COLORSPACE are
|
||||
* defined. When COLORSPACE is switched on all the colorspace-defining
|
||||
* chunks should be enabled, when GAMMA is switched on all the gamma-defining
|
||||
* chunks should be enabled. If this is not done it becomes possible to read
|
||||
* inconsistent PNG files and assign a probably incorrect interpretation to
|
||||
* the information. (In other words, by carefully choosing which chunks to
|
||||
* recognize the system configuration can select an interpretation for PNG
|
||||
* files containing ambiguous data and this will result in inconsistent
|
||||
* behavior between different libpng builds!)
|
||||
*/
|
||||
png_fixed_point gamma;
|
||||
png_colorspace colorspace;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_sRGB_SUPPORTED
|
||||
/* GR-P, 0.96a */
|
||||
/* Data valid if (valid & PNG_INFO_sRGB) non-zero. */
|
||||
png_byte srgb_intent; /* sRGB rendering intent [0, 1, 2, or 3] */
|
||||
#ifdef PNG_iCCP_SUPPORTED
|
||||
/* iCCP chunk data. */
|
||||
png_charp iccp_name; /* profile name */
|
||||
png_bytep iccp_profile; /* International Color Consortium profile data */
|
||||
png_uint_32 iccp_proflen; /* ICC profile data length */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_TEXT_SUPPORTED
|
||||
@ -136,7 +149,7 @@ struct png_info_def
|
||||
int num_text; /* number of comments read or comments to write */
|
||||
int max_text; /* current size of text array */
|
||||
png_textp text; /* array of comments read or comments to write */
|
||||
#endif /* PNG_TEXT_SUPPORTED */
|
||||
#endif /* TEXT */
|
||||
|
||||
#ifdef PNG_tIME_SUPPORTED
|
||||
/* The tIME chunk holds the last time the displayed image data was
|
||||
@ -211,23 +224,6 @@ defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
png_uint_16p hist;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_cHRM_SUPPORTED
|
||||
/* The cHRM chunk describes the CIE color characteristics of the monitor
|
||||
* on which the PNG was created. This data allows the viewer to do gamut
|
||||
* mapping of the input image to ensure that the viewer sees the same
|
||||
* colors in the image as the creator. Values are in the range
|
||||
* [0.0, 0.8]. Data valid if (valid & PNG_INFO_cHRM) non-zero.
|
||||
*/
|
||||
png_fixed_point x_white;
|
||||
png_fixed_point y_white;
|
||||
png_fixed_point x_red;
|
||||
png_fixed_point y_red;
|
||||
png_fixed_point x_green;
|
||||
png_fixed_point y_green;
|
||||
png_fixed_point x_blue;
|
||||
png_fixed_point y_blue;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_pCAL_SUPPORTED
|
||||
/* The pCAL chunk describes a transformation between the stored pixel
|
||||
* values and original physical data values used to create the image.
|
||||
@ -252,25 +248,20 @@ defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
/* New members added in libpng-1.0.6 */
|
||||
png_uint_32 free_me; /* flags items libpng is responsible for freeing */
|
||||
|
||||
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) || \
|
||||
defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED)
|
||||
#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
/* Storage for unknown chunks that the library doesn't recognize. */
|
||||
png_unknown_chunkp unknown_chunks;
|
||||
int unknown_chunks_num;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_iCCP_SUPPORTED
|
||||
/* iCCP chunk data. */
|
||||
png_charp iccp_name; /* profile name */
|
||||
png_bytep iccp_profile; /* International Color Consortium profile data */
|
||||
png_uint_32 iccp_proflen; /* ICC profile data length */
|
||||
png_byte iccp_compression; /* Always zero */
|
||||
/* The type of this field is limited by the type of
|
||||
* png_struct::user_chunk_cache_max, else overflow can occur.
|
||||
*/
|
||||
int unknown_chunks_num;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_sPLT_SUPPORTED
|
||||
/* Data on sPLT chunks (there may be more than one). */
|
||||
png_sPLT_tp splt_palettes;
|
||||
png_uint_32 splt_palettes_num;
|
||||
int splt_palettes_num; /* Match type returned by png_get API */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_sCAL_SUPPORTED
|
||||
|
@ -34,69 +34,47 @@
|
||||
* file and, per its terms, should not be removed:
|
||||
*/
|
||||
|
||||
/* libpng version 1.5.4 - last changed on June 22, 2011 */
|
||||
/* libpng version 1.6.16,December 22, 2014 */
|
||||
|
||||
/* Copyright (c) 1998-2011 Glenn Randers-Pehrson */
|
||||
/* Copyright (c) 1998-2014 Glenn Randers-Pehrson */
|
||||
|
||||
/* This code is released under the libpng license. */
|
||||
/* For conditions of distribution and use, see the disclaimer */
|
||||
/* and license in png.h */
|
||||
|
||||
/* pnglibconf.h */
|
||||
/* Machine generated file: DO NOT EDIT */
|
||||
/* Derived from: scripts/pnglibconf.dfa */
|
||||
/* If you edit this file by hand you must obey the rules expressed in */
|
||||
/* pnglibconf.dfa with respect to the dependencies between the following */
|
||||
/* symbols. It is much better to generate a new file using */
|
||||
/* scripts/libpngconf.mak */
|
||||
|
||||
#ifndef PNGLCONF_H
|
||||
#define PNGLCONF_H
|
||||
/* settings */
|
||||
#define PNG_API_RULE 0
|
||||
#define PNG_CALLOC_SUPPORTED
|
||||
#define PNG_COST_SHIFT 3
|
||||
#define PNG_DEFAULT_READ_MACROS 1
|
||||
#define PNG_GAMMA_THRESHOLD_FIXED 5000
|
||||
#define PNG_MAX_GAMMA_8 11
|
||||
#define PNG_QUANTIZE_BLUE_BITS 5
|
||||
#define PNG_QUANTIZE_GREEN_BITS 5
|
||||
#define PNG_QUANTIZE_RED_BITS 5
|
||||
#define PNG_sCAL_PRECISION 5
|
||||
#define PNG_USER_CHUNK_CACHE_MAX 0
|
||||
#define PNG_USER_CHUNK_MALLOC_MAX 0
|
||||
#define PNG_USER_HEIGHT_MAX 1000000L
|
||||
#define PNG_USER_WIDTH_MAX 1000000L
|
||||
#define PNG_WEIGHT_SHIFT 8
|
||||
#define PNG_ZBUF_SIZE 8192
|
||||
/* end of settings */
|
||||
/* options */
|
||||
#define PNG_16BIT_SUPPORTED
|
||||
#define PNG_ALIGN_MEMORY_SUPPORTED
|
||||
#define PNG_ALIGNED_MEMORY_SUPPORTED
|
||||
/*#undef PNG_ARM_NEON_API_SUPPORTED*/
|
||||
/*#undef PNG_ARM_NEON_CHECK_SUPPORTED*/
|
||||
#define PNG_BENIGN_ERRORS_SUPPORTED
|
||||
#define PNG_bKGD_SUPPORTED
|
||||
#define PNG_BENIGN_READ_ERRORS_SUPPORTED
|
||||
/*#undef PNG_BENIGN_WRITE_ERRORS_SUPPORTED*/
|
||||
#define PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED
|
||||
#define PNG_CHECK_cHRM_SUPPORTED
|
||||
#define PNG_cHRM_SUPPORTED
|
||||
#define PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||
#define PNG_COLORSPACE_SUPPORTED
|
||||
#define PNG_CONSOLE_IO_SUPPORTED
|
||||
#define PNG_CONVERT_tIME_SUPPORTED
|
||||
/*#undef PNG_CONVERT_tIME_SUPPORTED*/
|
||||
#define PNG_EASY_ACCESS_SUPPORTED
|
||||
/*#undef PNG_ERROR_NUMBERS_SUPPORTED*/
|
||||
#define PNG_ERROR_TEXT_SUPPORTED
|
||||
#define PNG_FIXED_POINT_SUPPORTED
|
||||
#define PNG_FLOATING_ARITHMETIC_SUPPORTED
|
||||
#define PNG_FLOATING_POINT_SUPPORTED
|
||||
#define PNG_gAMA_SUPPORTED
|
||||
#define PNG_FORMAT_AFIRST_SUPPORTED
|
||||
#define PNG_FORMAT_BGR_SUPPORTED
|
||||
#define PNG_GAMMA_SUPPORTED
|
||||
#define PNG_GET_PALETTE_MAX_SUPPORTED
|
||||
#define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||
#define PNG_hIST_SUPPORTED
|
||||
#define PNG_iCCP_SUPPORTED
|
||||
#define PNG_INCH_CONVERSIONS_SUPPORTED
|
||||
#define PNG_INFO_IMAGE_SUPPORTED
|
||||
#define PNG_IO_STATE_SUPPORTED
|
||||
#define PNG_iTXt_SUPPORTED
|
||||
#define PNG_MNG_FEATURES_SUPPORTED
|
||||
#define PNG_oFFs_SUPPORTED
|
||||
#define PNG_pCAL_SUPPORTED
|
||||
#define PNG_pHYs_SUPPORTED
|
||||
#define PNG_POINTER_INDEXING_SUPPORTED
|
||||
#define PNG_PROGRESSIVE_READ_SUPPORTED
|
||||
#define PNG_READ_16BIT_SUPPORTED
|
||||
@ -104,67 +82,73 @@
|
||||
#define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
|
||||
#define PNG_READ_BACKGROUND_SUPPORTED
|
||||
#define PNG_READ_BGR_SUPPORTED
|
||||
#define PNG_READ_bKGD_SUPPORTED
|
||||
#define PNG_READ_cHRM_SUPPORTED
|
||||
#define PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||
#define PNG_READ_COMPOSITE_NODIV_SUPPORTED
|
||||
#define PNG_READ_COMPRESSED_TEXT_SUPPORTED
|
||||
#define PNG_READ_EXPAND_16_SUPPORTED
|
||||
#define PNG_READ_EXPAND_SUPPORTED
|
||||
#define PNG_READ_FILLER_SUPPORTED
|
||||
#define PNG_READ_gAMA_SUPPORTED
|
||||
#define PNG_READ_GAMMA_SUPPORTED
|
||||
#define PNG_READ_GET_PALETTE_MAX_SUPPORTED
|
||||
#define PNG_READ_GRAY_TO_RGB_SUPPORTED
|
||||
#define PNG_READ_hIST_SUPPORTED
|
||||
#define PNG_READ_iCCP_SUPPORTED
|
||||
#define PNG_READ_INTERLACING_SUPPORTED
|
||||
#define PNG_READ_INT_FUNCTIONS_SUPPORTED
|
||||
#define PNG_READ_INVERT_ALPHA_SUPPORTED
|
||||
#define PNG_READ_INVERT_SUPPORTED
|
||||
#define PNG_READ_iTXt_SUPPORTED
|
||||
#define PNG_READ_oFFs_SUPPORTED
|
||||
#define PNG_READ_OPT_PLTE_SUPPORTED
|
||||
#define PNG_READ_PACK_SUPPORTED
|
||||
#define PNG_READ_PACKSWAP_SUPPORTED
|
||||
#define PNG_READ_pCAL_SUPPORTED
|
||||
#define PNG_READ_pHYs_SUPPORTED
|
||||
#define PNG_READ_PACK_SUPPORTED
|
||||
#define PNG_READ_QUANTIZE_SUPPORTED
|
||||
#define PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||
#define PNG_READ_sBIT_SUPPORTED
|
||||
#define PNG_READ_SCALE_16_TO_8_SUPPORTED
|
||||
#define PNG_READ_sCAL_SUPPORTED
|
||||
#define PNG_READ_SHIFT_SUPPORTED
|
||||
#define PNG_READ_sPLT_SUPPORTED
|
||||
#define PNG_READ_sRGB_SUPPORTED
|
||||
#define PNG_READ_STRIP_16_TO_8_SUPPORTED
|
||||
#define PNG_READ_STRIP_ALPHA_SUPPORTED
|
||||
#define PNG_READ_SUPPORTED
|
||||
#define PNG_READ_SWAP_ALPHA_SUPPORTED
|
||||
#define PNG_READ_SWAP_SUPPORTED
|
||||
#define PNG_READ_tEXt_SUPPORTED
|
||||
#define PNG_READ_TEXT_SUPPORTED
|
||||
#define PNG_READ_tIME_SUPPORTED
|
||||
#define PNG_READ_TRANSFORMS_SUPPORTED
|
||||
#define PNG_READ_tRNS_SUPPORTED
|
||||
#define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
|
||||
#define PNG_READ_USER_CHUNKS_SUPPORTED
|
||||
#define PNG_READ_USER_TRANSFORM_SUPPORTED
|
||||
#define PNG_READ_bKGD_SUPPORTED
|
||||
#define PNG_READ_cHRM_SUPPORTED
|
||||
#define PNG_READ_gAMA_SUPPORTED
|
||||
#define PNG_READ_hIST_SUPPORTED
|
||||
#define PNG_READ_iCCP_SUPPORTED
|
||||
#define PNG_READ_iTXt_SUPPORTED
|
||||
#define PNG_READ_oFFs_SUPPORTED
|
||||
#define PNG_READ_pCAL_SUPPORTED
|
||||
#define PNG_READ_pHYs_SUPPORTED
|
||||
#define PNG_READ_sBIT_SUPPORTED
|
||||
#define PNG_READ_sCAL_SUPPORTED
|
||||
#define PNG_READ_sPLT_SUPPORTED
|
||||
#define PNG_READ_sRGB_SUPPORTED
|
||||
#define PNG_READ_tEXt_SUPPORTED
|
||||
#define PNG_READ_tIME_SUPPORTED
|
||||
#define PNG_READ_tRNS_SUPPORTED
|
||||
#define PNG_READ_zTXt_SUPPORTED
|
||||
#define PNG_SAVE_INT_32_SUPPORTED
|
||||
#define PNG_sBIT_SUPPORTED
|
||||
#define PNG_sCAL_SUPPORTED
|
||||
/*#undef PNG_SAFE_LIMITS_SUPPORTED*/
|
||||
/*#undef PNG_SAVE_INT_32_SUPPORTED*/
|
||||
#define PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
#define PNG_SEQUENTIAL_READ_SUPPORTED
|
||||
#define PNG_SETJMP_SUPPORTED
|
||||
#define PNG_SET_CHUNK_CACHE_LIMIT_SUPPORTED
|
||||
#define PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED
|
||||
#define PNG_SETJMP_SUPPORTED
|
||||
#define PNG_SET_OPTION_SUPPORTED
|
||||
#define PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
|
||||
#define PNG_SET_USER_LIMITS_SUPPORTED
|
||||
#define PNG_sPLT_SUPPORTED
|
||||
#define PNG_sRGB_SUPPORTED
|
||||
#define PNG_SIMPLIFIED_READ_AFIRST_SUPPORTED
|
||||
#define PNG_SIMPLIFIED_READ_BGR_SUPPORTED
|
||||
#define PNG_SIMPLIFIED_READ_SUPPORTED
|
||||
/*#undef PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED*/
|
||||
/*#undef PNG_SIMPLIFIED_WRITE_BGR_SUPPORTED*/
|
||||
/*#undef PNG_SIMPLIFIED_WRITE_SUPPORTED*/
|
||||
#define PNG_STDIO_SUPPORTED
|
||||
#define PNG_tEXt_SUPPORTED
|
||||
#define PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
#define PNG_TEXT_SUPPORTED
|
||||
#define PNG_TIME_RFC1123_SUPPORTED
|
||||
#define PNG_tIME_SUPPORTED
|
||||
#define PNG_tRNS_SUPPORTED
|
||||
#define PNG_UNKNOWN_CHUNKS_SUPPORTED
|
||||
#define PNG_USER_CHUNKS_SUPPORTED
|
||||
#define PNG_USER_LIMITS_SUPPORTED
|
||||
@ -172,6 +156,91 @@
|
||||
#define PNG_USER_TRANSFORM_INFO_SUPPORTED
|
||||
#define PNG_USER_TRANSFORM_PTR_SUPPORTED
|
||||
#define PNG_WARNINGS_SUPPORTED
|
||||
/*#undef PNG_WRITE_16BIT_SUPPORTED*/
|
||||
/*#undef PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED*/
|
||||
/*#undef PNG_WRITE_BGR_SUPPORTED*/
|
||||
/*#undef PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED*/
|
||||
/*#undef PNG_WRITE_COMPRESSED_TEXT_SUPPORTED*/
|
||||
/*#undef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED*/
|
||||
/*#undef PNG_WRITE_FILLER_SUPPORTED*/
|
||||
/*#undef PNG_WRITE_FILTER_SUPPORTED*/
|
||||
/*#undef PNG_WRITE_FLUSH_SUPPORTED*/
|
||||
/*#undef PNG_WRITE_GET_PALETTE_MAX_SUPPORTED*/
|
||||
/*#undef PNG_WRITE_INTERLACING_SUPPORTED*/
|
||||
/*#undef PNG_WRITE_INT_FUNCTIONS_SUPPORTED*/
|
||||
/*#undef PNG_WRITE_INVERT_ALPHA_SUPPORTED*/
|
||||
/*#undef PNG_WRITE_INVERT_SUPPORTED*/
|
||||
/*#undef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED*/
|
||||
/*#undef PNG_WRITE_PACKSWAP_SUPPORTED*/
|
||||
/*#undef PNG_WRITE_PACK_SUPPORTED*/
|
||||
/*#undef PNG_WRITE_SHIFT_SUPPORTED*/
|
||||
/*#undef PNG_WRITE_SUPPORTED*/
|
||||
/*#undef PNG_WRITE_SWAP_ALPHA_SUPPORTED*/
|
||||
/*#undef PNG_WRITE_SWAP_SUPPORTED*/
|
||||
/*#undef PNG_WRITE_TEXT_SUPPORTED*/
|
||||
/*#undef PNG_WRITE_TRANSFORMS_SUPPORTED*/
|
||||
/*#undef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED*/
|
||||
/*#undef PNG_WRITE_USER_TRANSFORM_SUPPORTED*/
|
||||
/*#undef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED*/
|
||||
/*#undef PNG_WRITE_bKGD_SUPPORTED*/
|
||||
/*#undef PNG_WRITE_cHRM_SUPPORTED*/
|
||||
/*#undef PNG_WRITE_gAMA_SUPPORTED*/
|
||||
/*#undef PNG_WRITE_hIST_SUPPORTED*/
|
||||
/*#undef PNG_WRITE_iCCP_SUPPORTED*/
|
||||
/*#undef PNG_WRITE_iTXt_SUPPORTED*/
|
||||
/*#undef PNG_WRITE_oFFs_SUPPORTED*/
|
||||
/*#undef PNG_WRITE_pCAL_SUPPORTED*/
|
||||
/*#undef PNG_WRITE_pHYs_SUPPORTED*/
|
||||
/*#undef PNG_WRITE_sBIT_SUPPORTED*/
|
||||
/*#undef PNG_WRITE_sCAL_SUPPORTED*/
|
||||
/*#undef PNG_WRITE_sPLT_SUPPORTED*/
|
||||
/*#undef PNG_WRITE_sRGB_SUPPORTED*/
|
||||
/*#undef PNG_WRITE_tEXt_SUPPORTED*/
|
||||
/*#undef PNG_WRITE_tIME_SUPPORTED*/
|
||||
/*#undef PNG_WRITE_tRNS_SUPPORTED*/
|
||||
/*#undef PNG_WRITE_zTXt_SUPPORTED*/
|
||||
#define PNG_bKGD_SUPPORTED
|
||||
#define PNG_cHRM_SUPPORTED
|
||||
#define PNG_gAMA_SUPPORTED
|
||||
#define PNG_hIST_SUPPORTED
|
||||
#define PNG_iCCP_SUPPORTED
|
||||
#define PNG_iTXt_SUPPORTED
|
||||
#define PNG_oFFs_SUPPORTED
|
||||
#define PNG_pCAL_SUPPORTED
|
||||
#define PNG_pHYs_SUPPORTED
|
||||
#define PNG_sBIT_SUPPORTED
|
||||
#define PNG_sCAL_SUPPORTED
|
||||
#define PNG_sPLT_SUPPORTED
|
||||
#define PNG_sRGB_SUPPORTED
|
||||
#define PNG_tEXt_SUPPORTED
|
||||
#define PNG_tIME_SUPPORTED
|
||||
#define PNG_tRNS_SUPPORTED
|
||||
#define PNG_zTXt_SUPPORTED
|
||||
/* end of options */
|
||||
/* settings */
|
||||
#define PNG_API_RULE 0
|
||||
#define PNG_COST_SHIFT 3
|
||||
#define PNG_DEFAULT_READ_MACROS 1
|
||||
#define PNG_GAMMA_THRESHOLD_FIXED 5000
|
||||
#define PNG_IDAT_READ_SIZE PNG_ZBUF_SIZE
|
||||
#define PNG_INFLATE_BUF_SIZE 1024
|
||||
#define PNG_MAX_GAMMA_8 11
|
||||
#define PNG_QUANTIZE_BLUE_BITS 5
|
||||
#define PNG_QUANTIZE_GREEN_BITS 5
|
||||
#define PNG_QUANTIZE_RED_BITS 5
|
||||
#define PNG_TEXT_Z_DEFAULT_COMPRESSION (-1)
|
||||
#define PNG_TEXT_Z_DEFAULT_STRATEGY 0
|
||||
#define PNG_USER_CHUNK_CACHE_MAX 0
|
||||
#define PNG_USER_CHUNK_MALLOC_MAX 0
|
||||
#define PNG_USER_HEIGHT_MAX 1000000
|
||||
#define PNG_USER_WIDTH_MAX 1000000
|
||||
#define PNG_WEIGHT_SHIFT 8
|
||||
#define PNG_ZBUF_SIZE 8192
|
||||
#define PNG_ZLIB_VERNUM 0
|
||||
#define PNG_Z_DEFAULT_COMPRESSION (-1)
|
||||
#define PNG_Z_DEFAULT_NOFILTER_STRATEGY 0
|
||||
#define PNG_Z_DEFAULT_STRATEGY 1
|
||||
#define PNG_sCAL_PRECISION 5
|
||||
#define PNG_sRGB_PROFILE_CHECKS 2
|
||||
/* end of settings */
|
||||
#endif /* PNGLCONF_H */
|
||||
|
@ -29,8 +29,8 @@
|
||||
* However, the following notice accompanied the original version of this
|
||||
* file and, per its terms, should not be removed:
|
||||
*
|
||||
* Last changed in libpng 1.5.4 [July 7, 2011]
|
||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.15 [November 20, 2014]
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@ -48,457 +48,23 @@
|
||||
#include "pngpriv.h"
|
||||
|
||||
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
||||
|
||||
/* Borland DOS special memory handler */
|
||||
#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
|
||||
/* If you change this, be sure to change the one in png.h also */
|
||||
|
||||
/* Allocate memory for a png_struct. The malloc and memset can be replaced
|
||||
by a single call to calloc() if this is thought to improve performance. */
|
||||
PNG_FUNCTION(png_voidp /* PRIVATE */,
|
||||
png_create_struct,(int type),PNG_ALLOCATED)
|
||||
{
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
return (png_create_struct_2(type, NULL, NULL));
|
||||
}
|
||||
|
||||
/* Alternate version of png_create_struct, for use with user-defined malloc. */
|
||||
PNG_FUNCTION(png_voidp /* PRIVATE */,
|
||||
png_create_struct_2,(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr),
|
||||
PNG_ALLOCATED)
|
||||
{
|
||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
||||
png_size_t size;
|
||||
png_voidp struct_ptr;
|
||||
|
||||
if (type == PNG_STRUCT_INFO)
|
||||
size = png_sizeof(png_info);
|
||||
|
||||
else if (type == PNG_STRUCT_PNG)
|
||||
size = png_sizeof(png_struct);
|
||||
|
||||
else
|
||||
return (png_get_copyright(NULL));
|
||||
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
if (malloc_fn != NULL)
|
||||
{
|
||||
png_struct dummy_struct;
|
||||
png_structp png_ptr = &dummy_struct;
|
||||
png_ptr->mem_ptr=mem_ptr;
|
||||
struct_ptr = (*(malloc_fn))(png_ptr, (png_uint_32)size);
|
||||
}
|
||||
|
||||
else
|
||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
||||
struct_ptr = (png_voidp)farmalloc(size);
|
||||
if (struct_ptr != NULL)
|
||||
png_memset(struct_ptr, 0, size);
|
||||
|
||||
return (struct_ptr);
|
||||
}
|
||||
|
||||
/* Free memory allocated by a png_create_struct() call */
|
||||
/* Free a png_struct */
|
||||
void /* PRIVATE */
|
||||
png_destroy_struct(png_voidp struct_ptr)
|
||||
png_destroy_png_struct(png_structrp png_ptr)
|
||||
{
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
png_destroy_struct_2(struct_ptr, NULL, NULL);
|
||||
}
|
||||
|
||||
/* Free memory allocated by a png_create_struct() call */
|
||||
void /* PRIVATE */
|
||||
png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn,
|
||||
png_voidp mem_ptr)
|
||||
{
|
||||
# endif
|
||||
if (struct_ptr != NULL)
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
if (free_fn != NULL)
|
||||
{
|
||||
png_struct dummy_struct;
|
||||
png_structp png_ptr = &dummy_struct;
|
||||
png_ptr->mem_ptr=mem_ptr;
|
||||
(*(free_fn))(png_ptr, struct_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
||||
farfree (struct_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
/* Allocate memory. For reasonable files, size should never exceed
|
||||
* 64K. However, zlib may allocate more then 64K if you don't tell
|
||||
* it not to. See zconf.h and png.h for more information. zlib does
|
||||
* need to allocate exactly 64K, so whatever you call here must
|
||||
* have the ability to do that.
|
||||
*
|
||||
* Borland seems to have a problem in DOS mode for exactly 64K.
|
||||
* It gives you a segment with an offset of 8 (perhaps to store its
|
||||
* memory stuff). zlib doesn't like this at all, so we have to
|
||||
* detect and deal with it. This code should not be needed in
|
||||
* Windows or OS/2 modes, and only in 16 bit mode. This code has
|
||||
* been updated by Alexander Lehmann for version 0.89 to waste less
|
||||
* memory.
|
||||
*
|
||||
* Note that we can't use png_size_t for the "size" declaration,
|
||||
* since on some systems a png_size_t is a 16-bit quantity, and as a
|
||||
* result, we would be truncating potentially larger memory requests
|
||||
* (which should cause a fatal error) and introducing major problems.
|
||||
*/
|
||||
PNG_FUNCTION(png_voidp,PNGAPI
|
||||
png_calloc,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
||||
{
|
||||
png_voidp ret;
|
||||
|
||||
ret = (png_malloc(png_ptr, size));
|
||||
|
||||
if (ret != NULL)
|
||||
png_memset(ret,0,(png_size_t)size);
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
PNG_FUNCTION(png_voidp,PNGAPI
|
||||
png_malloc,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
||||
{
|
||||
png_voidp ret;
|
||||
|
||||
if (png_ptr == NULL || size == 0)
|
||||
return (NULL);
|
||||
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
if (png_ptr->malloc_fn != NULL)
|
||||
ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size));
|
||||
|
||||
else
|
||||
ret = (png_malloc_default(png_ptr, size));
|
||||
|
||||
if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
||||
png_error(png_ptr, "Out of memory");
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
PNG_FUNCTION(png_voidp,PNGAPI
|
||||
png_malloc_default,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
||||
{
|
||||
png_voidp ret;
|
||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
||||
|
||||
if (png_ptr == NULL || size == 0)
|
||||
return (NULL);
|
||||
|
||||
# ifdef PNG_MAX_MALLOC_64K
|
||||
if (size > (png_uint_32)65536L)
|
||||
{
|
||||
png_warning(png_ptr, "Cannot Allocate > 64K");
|
||||
ret = NULL;
|
||||
}
|
||||
|
||||
else
|
||||
# endif
|
||||
|
||||
if (size != (size_t)size)
|
||||
ret = NULL;
|
||||
|
||||
else if (size == (png_uint_32)65536L)
|
||||
{
|
||||
if (png_ptr->offset_table == NULL)
|
||||
{
|
||||
/* Try to see if we need to do any of this fancy stuff */
|
||||
ret = farmalloc(size);
|
||||
if (ret == NULL || ((png_size_t)ret & 0xffff))
|
||||
{
|
||||
int num_blocks;
|
||||
png_uint_32 total_size;
|
||||
png_bytep table;
|
||||
int i, mem_level, window_bits;
|
||||
png_byte huge * hptr;
|
||||
int window_bits
|
||||
|
||||
if (ret != NULL)
|
||||
{
|
||||
farfree(ret);
|
||||
ret = NULL;
|
||||
}
|
||||
|
||||
window_bits =
|
||||
png_ptr->zlib_window_bits >= png_ptr->zlib_text_window_bits ?
|
||||
png_ptr->zlib_window_bits : png_ptr->zlib_text_window_bits;
|
||||
|
||||
if (window_bits > 14)
|
||||
num_blocks = (int)(1 << (window_bits - 14));
|
||||
|
||||
else
|
||||
num_blocks = 1;
|
||||
|
||||
mem_level =
|
||||
png_ptr->zlib_mem_level >= png_ptr->zlib_text_mem_level ?
|
||||
png_ptr->zlib_mem_level : png_ptr->zlib_text_mem_level;
|
||||
|
||||
if (mem_level >= 7)
|
||||
num_blocks += (int)(1 << (mem_level - 7));
|
||||
|
||||
else
|
||||
num_blocks++;
|
||||
|
||||
total_size = ((png_uint_32)65536L) * (png_uint_32)num_blocks+16;
|
||||
|
||||
table = farmalloc(total_size);
|
||||
|
||||
if (table == NULL)
|
||||
{
|
||||
# ifndef PNG_USER_MEM_SUPPORTED
|
||||
if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
||||
png_error(png_ptr, "Out Of Memory"); /* Note "O", "M" */
|
||||
|
||||
else
|
||||
png_warning(png_ptr, "Out Of Memory");
|
||||
# endif
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
if ((png_size_t)table & 0xfff0)
|
||||
{
|
||||
# ifndef PNG_USER_MEM_SUPPORTED
|
||||
if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
||||
png_error(png_ptr,
|
||||
"Farmalloc didn't return normalized pointer");
|
||||
|
||||
else
|
||||
png_warning(png_ptr,
|
||||
"Farmalloc didn't return normalized pointer");
|
||||
# endif
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
png_ptr->offset_table = table;
|
||||
png_ptr->offset_table_ptr = farmalloc(num_blocks *
|
||||
png_sizeof(png_bytep));
|
||||
|
||||
if (png_ptr->offset_table_ptr == NULL)
|
||||
{
|
||||
# ifndef PNG_USER_MEM_SUPPORTED
|
||||
if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
||||
png_error(png_ptr, "Out Of memory"); /* Note "O", "m" */
|
||||
|
||||
else
|
||||
png_warning(png_ptr, "Out Of memory");
|
||||
# endif
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
hptr = (png_byte huge *)table;
|
||||
if ((png_size_t)hptr & 0xf)
|
||||
{
|
||||
hptr = (png_byte huge *)((long)(hptr) & 0xfffffff0L);
|
||||
hptr = hptr + 16L; /* "hptr += 16L" fails on Turbo C++ 3.0 */
|
||||
}
|
||||
|
||||
for (i = 0; i < num_blocks; i++)
|
||||
{
|
||||
png_ptr->offset_table_ptr[i] = (png_bytep)hptr;
|
||||
hptr = hptr + (png_uint_32)65536L; /* "+=" fails on TC++3.0 */
|
||||
}
|
||||
|
||||
png_ptr->offset_table_number = num_blocks;
|
||||
png_ptr->offset_table_count = 0;
|
||||
png_ptr->offset_table_count_free = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (png_ptr->offset_table_count >= png_ptr->offset_table_number)
|
||||
{
|
||||
# ifndef PNG_USER_MEM_SUPPORTED
|
||||
if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
||||
png_error(png_ptr, "Out of Memory"); /* Note "O" and "M" */
|
||||
|
||||
else
|
||||
png_warning(png_ptr, "Out of Memory");
|
||||
# endif
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
ret = png_ptr->offset_table_ptr[png_ptr->offset_table_count++];
|
||||
}
|
||||
|
||||
else
|
||||
ret = farmalloc(size);
|
||||
|
||||
# ifndef PNG_USER_MEM_SUPPORTED
|
||||
if (ret == NULL)
|
||||
{
|
||||
if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
||||
png_error(png_ptr, "Out of memory"); /* Note "o" and "m" */
|
||||
|
||||
else
|
||||
png_warning(png_ptr, "Out of memory"); /* Note "o" and "m" */
|
||||
}
|
||||
# endif
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/* Free a pointer allocated by png_malloc(). In the default
|
||||
* configuration, png_ptr is not used, but is passed in case it
|
||||
* is needed. If ptr is NULL, return without taking any action.
|
||||
*/
|
||||
void PNGAPI
|
||||
png_free(png_structp png_ptr, png_voidp ptr)
|
||||
{
|
||||
if (png_ptr == NULL || ptr == NULL)
|
||||
return;
|
||||
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
if (png_ptr->free_fn != NULL)
|
||||
{
|
||||
(*(png_ptr->free_fn))(png_ptr, ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
else
|
||||
png_free_default(png_ptr, ptr);
|
||||
}
|
||||
|
||||
void PNGAPI
|
||||
png_free_default(png_structp png_ptr, png_voidp ptr)
|
||||
{
|
||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
||||
|
||||
if (png_ptr == NULL || ptr == NULL)
|
||||
return;
|
||||
|
||||
if (png_ptr->offset_table != NULL)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < png_ptr->offset_table_count; i++)
|
||||
{
|
||||
if (ptr == png_ptr->offset_table_ptr[i])
|
||||
{
|
||||
ptr = NULL;
|
||||
png_ptr->offset_table_count_free++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (png_ptr->offset_table_count_free == png_ptr->offset_table_count)
|
||||
{
|
||||
farfree(png_ptr->offset_table);
|
||||
farfree(png_ptr->offset_table_ptr);
|
||||
png_ptr->offset_table = NULL;
|
||||
png_ptr->offset_table_ptr = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (ptr != NULL)
|
||||
farfree(ptr);
|
||||
}
|
||||
|
||||
#else /* Not the Borland DOS special memory handler */
|
||||
|
||||
/* Allocate memory for a png_struct or a png_info. The malloc and
|
||||
memset can be replaced by a single call to calloc() if this is thought
|
||||
to improve performance noticably. */
|
||||
PNG_FUNCTION(png_voidp /* PRIVATE */,
|
||||
png_create_struct,(int type),PNG_ALLOCATED)
|
||||
{
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
return (png_create_struct_2(type, NULL, NULL));
|
||||
}
|
||||
|
||||
/* Allocate memory for a png_struct or a png_info. The malloc and
|
||||
memset can be replaced by a single call to calloc() if this is thought
|
||||
to improve performance noticably. */
|
||||
PNG_FUNCTION(png_voidp /* PRIVATE */,
|
||||
png_create_struct_2,(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr),
|
||||
PNG_ALLOCATED)
|
||||
{
|
||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
||||
png_size_t size;
|
||||
png_voidp struct_ptr;
|
||||
|
||||
if (type == PNG_STRUCT_INFO)
|
||||
size = png_sizeof(png_info);
|
||||
|
||||
else if (type == PNG_STRUCT_PNG)
|
||||
size = png_sizeof(png_struct);
|
||||
|
||||
else
|
||||
return (NULL);
|
||||
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
if (malloc_fn != NULL)
|
||||
{
|
||||
png_struct dummy_struct;
|
||||
png_structp png_ptr = &dummy_struct;
|
||||
png_ptr->mem_ptr=mem_ptr;
|
||||
struct_ptr = (*(malloc_fn))(png_ptr, size);
|
||||
|
||||
if (struct_ptr != NULL)
|
||||
png_memset(struct_ptr, 0, size);
|
||||
|
||||
return (struct_ptr);
|
||||
}
|
||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
||||
|
||||
# if defined(__TURBOC__) && !defined(__FLAT__)
|
||||
struct_ptr = (png_voidp)farmalloc(size);
|
||||
# else
|
||||
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
||||
struct_ptr = (png_voidp)halloc(size, 1);
|
||||
# else
|
||||
struct_ptr = (png_voidp)malloc(size);
|
||||
# endif
|
||||
# endif
|
||||
|
||||
if (struct_ptr != NULL)
|
||||
png_memset(struct_ptr, 0, size);
|
||||
|
||||
return (struct_ptr);
|
||||
}
|
||||
|
||||
|
||||
/* Free memory allocated by a png_create_struct() call */
|
||||
void /* PRIVATE */
|
||||
png_destroy_struct(png_voidp struct_ptr)
|
||||
{
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
png_destroy_struct_2(struct_ptr, NULL, NULL);
|
||||
}
|
||||
|
||||
/* Free memory allocated by a png_create_struct() call */
|
||||
void /* PRIVATE */
|
||||
png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn,
|
||||
png_voidp mem_ptr)
|
||||
{
|
||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
||||
if (struct_ptr != NULL)
|
||||
{
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
if (free_fn != NULL)
|
||||
{
|
||||
png_struct dummy_struct;
|
||||
png_structp png_ptr = &dummy_struct;
|
||||
png_ptr->mem_ptr=mem_ptr;
|
||||
(*(free_fn))(png_ptr, struct_ptr);
|
||||
return;
|
||||
}
|
||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
||||
# if defined(__TURBOC__) && !defined(__FLAT__)
|
||||
farfree(struct_ptr);
|
||||
|
||||
# else
|
||||
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
||||
hfree(struct_ptr);
|
||||
|
||||
# else
|
||||
free(struct_ptr);
|
||||
|
||||
# endif
|
||||
# endif
|
||||
/* png_free might call png_error and may certainly call
|
||||
* png_get_mem_ptr, so fake a temporary png_struct to support this.
|
||||
*/
|
||||
png_struct dummy_struct = *png_ptr;
|
||||
memset(png_ptr, 0, (sizeof *png_ptr));
|
||||
png_free(&dummy_struct, png_ptr);
|
||||
|
||||
# ifdef PNG_SETJMP_SUPPORTED
|
||||
/* We may have a jmp_buf left to deallocate. */
|
||||
png_free_jmpbuf(&dummy_struct);
|
||||
# endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -508,167 +74,215 @@ png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn,
|
||||
* need to allocate exactly 64K, so whatever you call here must
|
||||
* have the ability to do that.
|
||||
*/
|
||||
|
||||
PNG_FUNCTION(png_voidp,PNGAPI
|
||||
png_calloc,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
||||
png_calloc,(png_const_structrp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
||||
{
|
||||
png_voidp ret;
|
||||
|
||||
ret = (png_malloc(png_ptr, size));
|
||||
ret = png_malloc(png_ptr, size);
|
||||
|
||||
if (ret != NULL)
|
||||
png_memset(ret,0,(png_size_t)size);
|
||||
memset(ret, 0, size);
|
||||
|
||||
return (ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
PNG_FUNCTION(png_voidp,PNGAPI
|
||||
png_malloc,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
||||
/* png_malloc_base, an internal function added at libpng 1.6.0, does the work of
|
||||
* allocating memory, taking into account limits and PNG_USER_MEM_SUPPORTED.
|
||||
* Checking and error handling must happen outside this routine; it returns NULL
|
||||
* if the allocation cannot be done (for any reason.)
|
||||
*/
|
||||
PNG_FUNCTION(png_voidp /* PRIVATE */,
|
||||
png_malloc_base,(png_const_structrp png_ptr, png_alloc_size_t size),
|
||||
PNG_ALLOCATED)
|
||||
{
|
||||
png_voidp ret;
|
||||
/* Moved to png_malloc_base from png_malloc_default in 1.6.0; the DOS
|
||||
* allocators have also been removed in 1.6.0, so any 16-bit system now has
|
||||
* to implement a user memory handler. This checks to be sure it isn't
|
||||
* called with big numbers.
|
||||
*/
|
||||
#ifndef PNG_USER_MEM_SUPPORTED
|
||||
PNG_UNUSED(png_ptr)
|
||||
#endif
|
||||
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
if (png_ptr == NULL || size == 0)
|
||||
return (NULL);
|
||||
|
||||
if (png_ptr->malloc_fn != NULL)
|
||||
ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size));
|
||||
|
||||
else
|
||||
ret = (png_malloc_default(png_ptr, size));
|
||||
|
||||
if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
||||
png_error(png_ptr, "Out of Memory");
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
PNG_FUNCTION(png_voidp,PNGAPI
|
||||
png_malloc_default,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
||||
{
|
||||
png_voidp ret;
|
||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
||||
|
||||
if (png_ptr == NULL || size == 0)
|
||||
return (NULL);
|
||||
|
||||
# ifdef PNG_MAX_MALLOC_64K
|
||||
if (size > (png_uint_32)65536L)
|
||||
if (size > 0 && size <= PNG_SIZE_MAX
|
||||
# ifdef PNG_MAX_MALLOC_64K
|
||||
&& size <= 65536U
|
||||
# endif
|
||||
)
|
||||
{
|
||||
# ifndef PNG_USER_MEM_SUPPORTED
|
||||
if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
||||
png_error(png_ptr, "Cannot Allocate > 64K");
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
if (png_ptr != NULL && png_ptr->malloc_fn != NULL)
|
||||
return png_ptr->malloc_fn(png_constcast(png_structrp,png_ptr), size);
|
||||
|
||||
else
|
||||
# endif
|
||||
return NULL;
|
||||
#endif
|
||||
return malloc((size_t)size); /* checked for truncation above */
|
||||
}
|
||||
# endif
|
||||
|
||||
/* Check for overflow */
|
||||
# if defined(__TURBOC__) && !defined(__FLAT__)
|
||||
|
||||
if (size != (unsigned long)size)
|
||||
ret = NULL;
|
||||
|
||||
else
|
||||
ret = farmalloc(size);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
# else
|
||||
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
||||
if (size != (unsigned long)size)
|
||||
ret = NULL;
|
||||
#if defined(PNG_TEXT_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) ||\
|
||||
defined(PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
/* This is really here only to work round a spurious warning in GCC 4.6 and 4.7
|
||||
* that arises because of the checks in png_realloc_array that are repeated in
|
||||
* png_malloc_array.
|
||||
*/
|
||||
static png_voidp
|
||||
png_malloc_array_checked(png_const_structrp png_ptr, int nelements,
|
||||
size_t element_size)
|
||||
{
|
||||
png_alloc_size_t req = nelements; /* known to be > 0 */
|
||||
|
||||
else
|
||||
ret = halloc(size, 1);
|
||||
if (req <= PNG_SIZE_MAX/element_size)
|
||||
return png_malloc_base(png_ptr, req * element_size);
|
||||
|
||||
# else
|
||||
if (size != (size_t)size)
|
||||
ret = NULL;
|
||||
/* The failure case when the request is too large */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
else
|
||||
ret = malloc((size_t)size);
|
||||
# endif
|
||||
# endif
|
||||
PNG_FUNCTION(png_voidp /* PRIVATE */,
|
||||
png_malloc_array,(png_const_structrp png_ptr, int nelements,
|
||||
size_t element_size),PNG_ALLOCATED)
|
||||
{
|
||||
if (nelements <= 0 || element_size == 0)
|
||||
png_error(png_ptr, "internal error: array alloc");
|
||||
|
||||
# ifndef PNG_USER_MEM_SUPPORTED
|
||||
if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
||||
png_error(png_ptr, "Out of Memory");
|
||||
# endif
|
||||
return png_malloc_array_checked(png_ptr, nelements, element_size);
|
||||
}
|
||||
|
||||
return (ret);
|
||||
PNG_FUNCTION(png_voidp /* PRIVATE */,
|
||||
png_realloc_array,(png_const_structrp png_ptr, png_const_voidp old_array,
|
||||
int old_elements, int add_elements, size_t element_size),PNG_ALLOCATED)
|
||||
{
|
||||
/* These are internal errors: */
|
||||
if (add_elements <= 0 || element_size == 0 || old_elements < 0 ||
|
||||
(old_array == NULL && old_elements > 0))
|
||||
png_error(png_ptr, "internal error: array realloc");
|
||||
|
||||
/* Check for overflow on the elements count (so the caller does not have to
|
||||
* check.)
|
||||
*/
|
||||
if (add_elements <= INT_MAX - old_elements)
|
||||
{
|
||||
png_voidp new_array = png_malloc_array_checked(png_ptr,
|
||||
old_elements+add_elements, element_size);
|
||||
|
||||
if (new_array != NULL)
|
||||
{
|
||||
/* Because png_malloc_array worked the size calculations below cannot
|
||||
* overflow.
|
||||
*/
|
||||
if (old_elements > 0)
|
||||
memcpy(new_array, old_array, element_size*(unsigned)old_elements);
|
||||
|
||||
memset((char*)new_array + element_size*(unsigned)old_elements, 0,
|
||||
element_size*(unsigned)add_elements);
|
||||
|
||||
return new_array;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL; /* error */
|
||||
}
|
||||
#endif /* TEXT || sPLT || STORE_UNKNOWN_CHUNKS */
|
||||
|
||||
/* Various functions that have different error handling are derived from this.
|
||||
* png_malloc always exists, but if PNG_USER_MEM_SUPPORTED is defined a separate
|
||||
* function png_malloc_default is also provided.
|
||||
*/
|
||||
PNG_FUNCTION(png_voidp,PNGAPI
|
||||
png_malloc,(png_const_structrp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
||||
{
|
||||
png_voidp ret;
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return NULL;
|
||||
|
||||
ret = png_malloc_base(png_ptr, size);
|
||||
|
||||
if (ret == NULL)
|
||||
png_error(png_ptr, "Out of memory"); /* 'm' means png_malloc */
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
PNG_FUNCTION(png_voidp,PNGAPI
|
||||
png_malloc_default,(png_const_structrp png_ptr, png_alloc_size_t size),
|
||||
PNG_ALLOCATED PNG_DEPRECATED)
|
||||
{
|
||||
png_voidp ret;
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return NULL;
|
||||
|
||||
/* Passing 'NULL' here bypasses the application provided memory handler. */
|
||||
ret = png_malloc_base(NULL/*use malloc*/, size);
|
||||
|
||||
if (ret == NULL)
|
||||
png_error(png_ptr, "Out of Memory"); /* 'M' means png_malloc_default */
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif /* USER_MEM */
|
||||
|
||||
/* This function was added at libpng version 1.2.3. The png_malloc_warn()
|
||||
* function will issue a png_warning and return NULL instead of issuing a
|
||||
* png_error, if it fails to allocate the requested memory.
|
||||
*/
|
||||
PNG_FUNCTION(png_voidp,PNGAPI
|
||||
png_malloc_warn,(png_const_structrp png_ptr, png_alloc_size_t size),
|
||||
PNG_ALLOCATED)
|
||||
{
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
png_voidp ret = png_malloc_base(png_ptr, size);
|
||||
|
||||
if (ret != NULL)
|
||||
return ret;
|
||||
|
||||
png_warning(png_ptr, "Out of memory");
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Free a pointer allocated by png_malloc(). If ptr is NULL, return
|
||||
* without taking any action.
|
||||
*/
|
||||
void PNGAPI
|
||||
png_free(png_structp png_ptr, png_voidp ptr)
|
||||
png_free(png_const_structrp png_ptr, png_voidp ptr)
|
||||
{
|
||||
if (png_ptr == NULL || ptr == NULL)
|
||||
return;
|
||||
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
if (png_ptr->free_fn != NULL)
|
||||
{
|
||||
(*(png_ptr->free_fn))(png_ptr, ptr);
|
||||
return;
|
||||
}
|
||||
png_ptr->free_fn(png_constcast(png_structrp,png_ptr), ptr);
|
||||
|
||||
else
|
||||
png_free_default(png_ptr, ptr);
|
||||
}
|
||||
|
||||
void PNGAPI
|
||||
png_free_default(png_structp png_ptr, png_voidp ptr)
|
||||
PNG_FUNCTION(void,PNGAPI
|
||||
png_free_default,(png_const_structrp png_ptr, png_voidp ptr),PNG_DEPRECATED)
|
||||
{
|
||||
if (png_ptr == NULL || ptr == NULL)
|
||||
return;
|
||||
#endif /* USER_MEM */
|
||||
|
||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
||||
|
||||
# if defined(__TURBOC__) && !defined(__FLAT__)
|
||||
farfree(ptr);
|
||||
|
||||
# else
|
||||
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
||||
hfree(ptr);
|
||||
|
||||
# else
|
||||
free(ptr);
|
||||
|
||||
# endif
|
||||
# endif
|
||||
}
|
||||
#endif /* Not Borland DOS special memory handler */
|
||||
|
||||
/* This function was added at libpng version 1.2.3. The png_malloc_warn()
|
||||
* function will set up png_malloc() to issue a png_warning and return NULL
|
||||
* instead of issuing a png_error, if it fails to allocate the requested
|
||||
* memory.
|
||||
*/
|
||||
PNG_FUNCTION(png_voidp,PNGAPI
|
||||
png_malloc_warn,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
||||
{
|
||||
png_voidp ptr;
|
||||
png_uint_32 save_flags;
|
||||
if (png_ptr == NULL)
|
||||
return (NULL);
|
||||
|
||||
save_flags = png_ptr->flags;
|
||||
png_ptr->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK;
|
||||
ptr = (png_voidp)png_malloc((png_structp)png_ptr, size);
|
||||
png_ptr->flags=save_flags;
|
||||
return(ptr);
|
||||
}
|
||||
|
||||
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
/* This function is called when the application wants to use another method
|
||||
* of allocating and freeing memory.
|
||||
*/
|
||||
void PNGAPI
|
||||
png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr
|
||||
png_set_mem_fn(png_structrp png_ptr, png_voidp mem_ptr, png_malloc_ptr
|
||||
malloc_fn, png_free_ptr free_fn)
|
||||
{
|
||||
if (png_ptr != NULL)
|
||||
@ -684,12 +298,12 @@ png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr
|
||||
* pointer before png_write_destroy and png_read_destroy are called.
|
||||
*/
|
||||
png_voidp PNGAPI
|
||||
png_get_mem_ptr(png_const_structp png_ptr)
|
||||
png_get_mem_ptr(png_const_structrp png_ptr)
|
||||
{
|
||||
if (png_ptr == NULL)
|
||||
return (NULL);
|
||||
return NULL;
|
||||
|
||||
return ((png_voidp)png_ptr->mem_ptr);
|
||||
return png_ptr->mem_ptr;
|
||||
}
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
||||
#endif /* USER_MEM */
|
||||
#endif /* READ || WRITE */
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -29,8 +29,8 @@
|
||||
* However, the following notice accompanied the original version of this
|
||||
* file and, per its terms, should not be removed:
|
||||
*
|
||||
* Last changed in libpng 1.5.0 [January 6, 2011]
|
||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.15 [November 20, 2014]
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@ -57,7 +57,7 @@
|
||||
* to read more then 64K on a 16 bit machine.
|
||||
*/
|
||||
void /* PRIVATE */
|
||||
png_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
png_read_data(png_structrp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
png_debug1(4, "reading %d bytes", (int)length);
|
||||
|
||||
@ -74,7 +74,6 @@ png_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
* read_data function and use it at run time with png_set_read_fn(), rather
|
||||
* than changing the library.
|
||||
*/
|
||||
# ifndef USE_FAR_KEYWORD
|
||||
void PNGCBAPI
|
||||
png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
@ -86,68 +85,11 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
/* fread() returns 0 on error, so it is OK to store this in a png_size_t
|
||||
* instead of an int, which is what fread() actually returns.
|
||||
*/
|
||||
check = fread(data, 1, length, (png_FILE_p)png_ptr->io_ptr);
|
||||
check = fread(data, 1, length, png_voidcast(png_FILE_p, png_ptr->io_ptr));
|
||||
|
||||
if (check != length)
|
||||
png_error(png_ptr, "Read Error");
|
||||
}
|
||||
# else
|
||||
/* This is the model-independent version. Since the standard I/O library
|
||||
can't handle far buffers in the medium and small models, we have to copy
|
||||
the data.
|
||||
*/
|
||||
|
||||
#define NEAR_BUF_SIZE 1024
|
||||
#define MIN(a,b) (a <= b ? a : b)
|
||||
|
||||
static void PNGCBAPI
|
||||
png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
png_size_t check;
|
||||
png_byte *n_data;
|
||||
png_FILE_p io_ptr;
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
/* Check if data really is near. If so, use usual code. */
|
||||
n_data = (png_byte *)CVT_PTR_NOCHECK(data);
|
||||
io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr);
|
||||
|
||||
if ((png_bytep)n_data == data)
|
||||
{
|
||||
check = fread(n_data, 1, length, io_ptr);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
png_byte buf[NEAR_BUF_SIZE];
|
||||
png_size_t read, remaining, err;
|
||||
check = 0;
|
||||
remaining = length;
|
||||
|
||||
do
|
||||
{
|
||||
read = MIN(NEAR_BUF_SIZE, remaining);
|
||||
err = fread(buf, 1, read, io_ptr);
|
||||
png_memcpy(data, buf, read); /* copy far buffer to near buffer */
|
||||
|
||||
if (err != read)
|
||||
break;
|
||||
|
||||
else
|
||||
check += err;
|
||||
|
||||
data += read;
|
||||
remaining -= read;
|
||||
}
|
||||
while (remaining != 0);
|
||||
}
|
||||
|
||||
if ((png_uint_32)check != (png_uint_32)length)
|
||||
png_error(png_ptr, "read Error");
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* This function allows the application to supply a new input function
|
||||
@ -170,7 +112,7 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
* be used.
|
||||
*/
|
||||
void PNGAPI
|
||||
png_set_read_fn(png_structp png_ptr, png_voidp io_ptr,
|
||||
png_set_read_fn(png_structrp png_ptr, png_voidp io_ptr,
|
||||
png_rw_ptr read_data_fn)
|
||||
{
|
||||
if (png_ptr == NULL)
|
||||
@ -188,6 +130,7 @@ png_set_read_fn(png_structp png_ptr, png_voidp io_ptr,
|
||||
png_ptr->read_data_fn = read_data_fn;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
/* It is an error to write to a read device */
|
||||
if (png_ptr->write_data_fn != NULL)
|
||||
{
|
||||
@ -196,9 +139,10 @@ png_set_read_fn(png_structp png_ptr, png_voidp io_ptr,
|
||||
"Can't set both read_data_fn and write_data_fn in the"
|
||||
" same structure");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_FLUSH_SUPPORTED
|
||||
png_ptr->output_flush_fn = NULL;
|
||||
#endif
|
||||
}
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
#endif /* READ */
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -29,11 +29,11 @@
|
||||
* However, the following notice accompanied the original version of this
|
||||
* file and, per its terms, should not be removed:
|
||||
*
|
||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
* Last changed in libpng 1.5.4 [July 7, 2011]
|
||||
* Last changed in libpng 1.6.1 [March 28, 2013]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@ -52,13 +52,130 @@
|
||||
* in this structure and is required for decompressing the LZ compressed
|
||||
* data in PNG files.
|
||||
*/
|
||||
#ifndef ZLIB_CONST
|
||||
/* We must ensure that zlib uses 'const' in declarations. */
|
||||
# define ZLIB_CONST
|
||||
#endif
|
||||
#include "zlib.h"
|
||||
#ifdef const
|
||||
/* zlib.h sometimes #defines const to nothing, undo this. */
|
||||
# undef const
|
||||
#endif
|
||||
|
||||
/* zlib.h has mediocre z_const use before 1.2.6, this stuff is for compatibility
|
||||
* with older builds.
|
||||
*/
|
||||
#if ZLIB_VERNUM < 0x1260
|
||||
# define PNGZ_MSG_CAST(s) png_constcast(char*,s)
|
||||
# define PNGZ_INPUT_CAST(b) png_constcast(png_bytep,b)
|
||||
#else
|
||||
# define PNGZ_MSG_CAST(s) (s)
|
||||
# define PNGZ_INPUT_CAST(b) (b)
|
||||
#endif
|
||||
|
||||
/* zlib.h declares a magic type 'uInt' that limits the amount of data that zlib
|
||||
* can handle at once. This type need be no larger than 16 bits (so maximum of
|
||||
* 65535), this define allows us to discover how big it is, but limited by the
|
||||
* maximuum for png_size_t. The value can be overriden in a library build
|
||||
* (pngusr.h, or set it in CPPFLAGS) and it works to set it to a considerably
|
||||
* lower value (e.g. 255 works). A lower value may help memory usage (slightly)
|
||||
* and may even improve performance on some systems (and degrade it on others.)
|
||||
*/
|
||||
#ifndef ZLIB_IO_MAX
|
||||
# define ZLIB_IO_MAX ((uInt)-1)
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
/* The type of a compression buffer list used by the write code. */
|
||||
typedef struct png_compression_buffer
|
||||
{
|
||||
struct png_compression_buffer *next;
|
||||
png_byte output[1]; /* actually zbuf_size */
|
||||
} png_compression_buffer, *png_compression_bufferp;
|
||||
|
||||
#define PNG_COMPRESSION_BUFFER_SIZE(pp)\
|
||||
(offsetof(png_compression_buffer, output) + (pp)->zbuffer_size)
|
||||
#endif
|
||||
|
||||
/* Colorspace support; structures used in png_struct, png_info and in internal
|
||||
* functions to hold and communicate information about the color space.
|
||||
*
|
||||
* PNG_COLORSPACE_SUPPORTED is only required if the application will perform
|
||||
* colorspace corrections, otherwise all the colorspace information can be
|
||||
* skipped and the size of libpng can be reduced (significantly) by compiling
|
||||
* out the colorspace support.
|
||||
*/
|
||||
#ifdef PNG_COLORSPACE_SUPPORTED
|
||||
/* The chromaticities of the red, green and blue colorants and the chromaticity
|
||||
* of the corresponding white point (i.e. of rgb(1.0,1.0,1.0)).
|
||||
*/
|
||||
typedef struct png_xy
|
||||
{
|
||||
png_fixed_point redx, redy;
|
||||
png_fixed_point greenx, greeny;
|
||||
png_fixed_point bluex, bluey;
|
||||
png_fixed_point whitex, whitey;
|
||||
} png_xy;
|
||||
|
||||
/* The same data as above but encoded as CIE XYZ values. When this data comes
|
||||
* from chromaticities the sum of the Y values is assumed to be 1.0
|
||||
*/
|
||||
typedef struct png_XYZ
|
||||
{
|
||||
png_fixed_point red_X, red_Y, red_Z;
|
||||
png_fixed_point green_X, green_Y, green_Z;
|
||||
png_fixed_point blue_X, blue_Y, blue_Z;
|
||||
} png_XYZ;
|
||||
#endif /* COLORSPACE */
|
||||
|
||||
#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)
|
||||
/* A colorspace is all the above plus, potentially, profile information,
|
||||
* however at present libpng does not use the profile internally so it is only
|
||||
* stored in the png_info struct (if iCCP is supported.) The rendering intent
|
||||
* is retained here and is checked.
|
||||
*
|
||||
* The file gamma encoding information is also stored here and gamma correction
|
||||
* is done by libpng, whereas color correction must currently be done by the
|
||||
* application.
|
||||
*/
|
||||
typedef struct png_colorspace
|
||||
{
|
||||
#ifdef PNG_GAMMA_SUPPORTED
|
||||
png_fixed_point gamma; /* File gamma */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_COLORSPACE_SUPPORTED
|
||||
png_xy end_points_xy; /* End points as chromaticities */
|
||||
png_XYZ end_points_XYZ; /* End points as CIE XYZ colorant values */
|
||||
png_uint_16 rendering_intent; /* Rendering intent of a profile */
|
||||
#endif
|
||||
|
||||
/* Flags are always defined to simplify the code. */
|
||||
png_uint_16 flags; /* As defined below */
|
||||
} png_colorspace, * PNG_RESTRICT png_colorspacerp;
|
||||
|
||||
typedef const png_colorspace * PNG_RESTRICT png_const_colorspacerp;
|
||||
|
||||
/* General flags for the 'flags' field */
|
||||
#define PNG_COLORSPACE_HAVE_GAMMA 0x0001
|
||||
#define PNG_COLORSPACE_HAVE_ENDPOINTS 0x0002
|
||||
#define PNG_COLORSPACE_HAVE_INTENT 0x0004
|
||||
#define PNG_COLORSPACE_FROM_gAMA 0x0008
|
||||
#define PNG_COLORSPACE_FROM_cHRM 0x0010
|
||||
#define PNG_COLORSPACE_FROM_sRGB 0x0020
|
||||
#define PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB 0x0040
|
||||
#define PNG_COLORSPACE_MATCHES_sRGB 0x0080 /* exact match on profile */
|
||||
#define PNG_COLORSPACE_INVALID 0x8000
|
||||
#define PNG_COLORSPACE_CANCEL(flags) (0xffff ^ (flags))
|
||||
#endif /* COLORSPACE || GAMMA */
|
||||
|
||||
struct png_struct_def
|
||||
{
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
jmp_buf longjmp_buffer; /* used in png_error */
|
||||
jmp_buf jmp_buf_local; /* New name in 1.6.0 for jmp_buf in png_struct */
|
||||
png_longjmp_ptr longjmp_fn;/* setjmp non-local goto function. */
|
||||
jmp_buf *jmp_buf_ptr; /* passed to longjmp_fn */
|
||||
size_t jmp_buf_size; /* size of the above, if allocated */
|
||||
#endif
|
||||
png_error_ptr error_fn; /* function for printing errors and aborting */
|
||||
#ifdef PNG_WARNINGS_SUPPORTED
|
||||
@ -91,22 +208,12 @@ struct png_struct_def
|
||||
png_uint_32 flags; /* flags indicating various things to libpng */
|
||||
png_uint_32 transformations; /* which transformations to perform */
|
||||
|
||||
z_stream zstream; /* pointer to decompression structure (below) */
|
||||
png_bytep zbuf; /* buffer for zlib */
|
||||
uInt zbuf_size; /* size of zbuf (typically 65536) */
|
||||
png_uint_32 zowner; /* ID (chunk type) of zstream owner, 0 if none */
|
||||
z_stream zstream; /* decompression structure */
|
||||
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
|
||||
/* Added in 1.5.4: state to keep track of whether the zstream has been
|
||||
* initialized and if so whether it is for IDAT or some other chunk.
|
||||
*/
|
||||
#define PNG_ZLIB_UNINITIALIZED 0
|
||||
#define PNG_ZLIB_FOR_IDAT 1
|
||||
#define PNG_ZLIB_FOR_TEXT 2 /* anything other than IDAT */
|
||||
#define PNG_ZLIB_USE_MASK 3 /* bottom two bits */
|
||||
#define PNG_ZLIB_IN_USE 4 /* a flag value */
|
||||
|
||||
png_uint_32 zlib_state; /* State of zlib initialization */
|
||||
/* End of material added at libpng 1.5.4 */
|
||||
png_compression_bufferp zbuffer_list; /* Created on demand during write */
|
||||
uInt zbuffer_size; /* size of the actual buffer */
|
||||
|
||||
int zlib_level; /* holds zlib compression level */
|
||||
int zlib_method; /* holds zlib compression method */
|
||||
@ -115,8 +222,7 @@ struct png_struct_def
|
||||
int zlib_strategy; /* holds zlib compression strategy */
|
||||
#endif
|
||||
/* Added at libpng 1.5.4 */
|
||||
#if defined(PNG_WRITE_COMPRESSED_TEXT_SUPPORTED) || \
|
||||
defined(PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED)
|
||||
#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
|
||||
int zlib_text_level; /* holds zlib compression level */
|
||||
int zlib_text_method; /* holds zlib compression method */
|
||||
int zlib_text_window_bits; /* holds zlib compression window bits */
|
||||
@ -124,6 +230,14 @@ struct png_struct_def
|
||||
int zlib_text_strategy; /* holds zlib compression strategy */
|
||||
#endif
|
||||
/* End of material added at libpng 1.5.4 */
|
||||
/* Added at libpng 1.6.0 */
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
int zlib_set_level; /* Actual values set into the zstream on write */
|
||||
int zlib_set_method;
|
||||
int zlib_set_window_bits;
|
||||
int zlib_set_mem_level;
|
||||
int zlib_set_strategy;
|
||||
#endif
|
||||
|
||||
png_uint_32 width; /* width of image in pixels */
|
||||
png_uint_32 height; /* height of image in pixels */
|
||||
@ -132,21 +246,32 @@ struct png_struct_def
|
||||
png_size_t rowbytes; /* size of row in bytes */
|
||||
png_uint_32 iwidth; /* width of current interlaced row in pixels */
|
||||
png_uint_32 row_number; /* current row in interlace pass */
|
||||
png_bytep prev_row; /* buffer to save previous (unfiltered) row */
|
||||
png_bytep row_buf; /* buffer to save current (unfiltered) row */
|
||||
png_uint_32 chunk_name; /* PNG_CHUNK() id of current chunk */
|
||||
png_bytep prev_row; /* buffer to save previous (unfiltered) row.
|
||||
* This is a pointer into big_prev_row
|
||||
*/
|
||||
png_bytep row_buf; /* buffer to save current (unfiltered) row.
|
||||
* This is a pointer into big_row_buf
|
||||
*/
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
png_bytep sub_row; /* buffer to save "sub" row when filtering */
|
||||
png_bytep up_row; /* buffer to save "up" row when filtering */
|
||||
png_bytep avg_row; /* buffer to save "avg" row when filtering */
|
||||
png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */
|
||||
png_row_info row_info; /* used for transformation routines */
|
||||
#endif
|
||||
png_size_t info_rowbytes; /* Added in 1.5.4: cache of updated row bytes */
|
||||
|
||||
png_uint_32 idat_size; /* current IDAT size for read */
|
||||
png_uint_32 crc; /* current chunk CRC value */
|
||||
png_colorp palette; /* palette from the input file */
|
||||
png_uint_16 num_palette; /* number of color entries in palette */
|
||||
|
||||
/* Added at libpng-1.5.10 */
|
||||
#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||
int num_palette_max; /* maximum palette index found in IDAT */
|
||||
#endif
|
||||
|
||||
png_uint_16 num_trans; /* number of transparency values */
|
||||
png_byte chunk_name[5]; /* null-terminated name of current chunk */
|
||||
png_byte compression; /* file compression type (always 0) */
|
||||
png_byte filter; /* file filter type (always 0) */
|
||||
png_byte interlaced; /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
|
||||
@ -154,12 +279,17 @@ struct png_struct_def
|
||||
png_byte do_filter; /* row filter flags (see PNG_FILTER_ below ) */
|
||||
png_byte color_type; /* color type of file */
|
||||
png_byte bit_depth; /* bit depth of file */
|
||||
png_byte usr_bit_depth; /* bit depth of users row */
|
||||
png_byte usr_bit_depth; /* bit depth of users row: write only */
|
||||
png_byte pixel_depth; /* number of bits per pixel */
|
||||
png_byte channels; /* number of channels in file */
|
||||
png_byte usr_channels; /* channels at start of write */
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
png_byte usr_channels; /* channels at start of write: write only */
|
||||
#endif
|
||||
png_byte sig_bytes; /* magic bytes read/written from start of file */
|
||||
|
||||
png_byte maximum_pixel_depth;
|
||||
/* pixel depth used for the row buffers */
|
||||
png_byte transformed_pixel_depth;
|
||||
/* pixel depth after read/write transforms */
|
||||
#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
|
||||
png_uint_16 filler; /* filler bytes for pixel expansion */
|
||||
#endif
|
||||
@ -172,7 +302,7 @@ struct png_struct_def
|
||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||
png_color_16 background_1; /* background normalized to gamma 1.0 */
|
||||
#endif
|
||||
#endif /* PNG_bKGD_SUPPORTED */
|
||||
#endif /* bKGD */
|
||||
|
||||
#ifdef PNG_WRITE_FLUSH_SUPPORTED
|
||||
png_flush_ptr output_flush_fn; /* Function for flushing output */
|
||||
@ -180,19 +310,20 @@ struct png_struct_def
|
||||
png_uint_32 flush_rows; /* number of rows written since last flush */
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||
int gamma_shift; /* number of "insignificant" bits in 16-bit gamma */
|
||||
png_fixed_point gamma; /* file gamma value */
|
||||
png_fixed_point screen_gamma; /* screen gamma value (display_exponent) */
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
png_bytep gamma_table; /* gamma table for 8-bit depth files */
|
||||
png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */
|
||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \
|
||||
defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \
|
||||
defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
|
||||
png_bytep gamma_from_1; /* converts from 1.0 to screen */
|
||||
png_bytep gamma_to_1; /* converts from file to 1.0 */
|
||||
png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */
|
||||
png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */
|
||||
png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */
|
||||
#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_sBIT_SUPPORTED)
|
||||
@ -228,14 +359,7 @@ struct png_struct_def
|
||||
int process_mode; /* what push library is currently doing */
|
||||
int cur_palette; /* current push library palette index */
|
||||
|
||||
# ifdef PNG_TEXT_SUPPORTED
|
||||
png_size_t current_text_size; /* current size of text input data */
|
||||
png_size_t current_text_left; /* how much text left to read in input */
|
||||
png_charp current_text; /* current text chunk buffer */
|
||||
png_charp current_text_ptr; /* current location in current_text */
|
||||
# endif /* PNG_PROGRESSIVE_READ_SUPPORTED && PNG_TEXT_SUPPORTED */
|
||||
|
||||
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
|
||||
#endif /* PROGRESSIVE_READ */
|
||||
|
||||
#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
|
||||
/* For the Borland special 64K segment handler */
|
||||
@ -251,10 +375,6 @@ struct png_struct_def
|
||||
png_bytep quantize_index; /* index translation for palette files */
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_QUANTIZE_SUPPORTED) || defined(PNG_hIST_SUPPORTED)
|
||||
png_uint_16p hist; /* histogram */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
||||
png_byte heuristic_method; /* heuristic for row filter selection */
|
||||
png_byte num_prev_filters; /* number of weights for previous rows */
|
||||
@ -265,9 +385,17 @@ struct png_struct_def
|
||||
png_uint_16p inv_filter_costs; /* 1/relative filter calculation cost */
|
||||
#endif
|
||||
|
||||
/* Options */
|
||||
#ifdef PNG_SET_OPTION_SUPPORTED
|
||||
png_byte options; /* On/off state (up to 4 options) */
|
||||
#endif
|
||||
|
||||
#if PNG_LIBPNG_VER < 10700
|
||||
/* To do: remove this from libpng-1.7 */
|
||||
#ifdef PNG_TIME_RFC1123_SUPPORTED
|
||||
char time_buffer[29]; /* String to hold RFC 1123 time text */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* New members added in libpng-1.0.6 */
|
||||
|
||||
@ -275,27 +403,31 @@ struct png_struct_def
|
||||
|
||||
#ifdef PNG_USER_CHUNKS_SUPPORTED
|
||||
png_voidp user_chunk_ptr;
|
||||
#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
|
||||
png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||
int num_chunk_list;
|
||||
png_bytep chunk_list;
|
||||
#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
|
||||
int unknown_default; /* As PNG_HANDLE_* */
|
||||
unsigned int num_chunk_list; /* Number of entries in the list */
|
||||
png_bytep chunk_list; /* List of png_byte[5]; the textual chunk name
|
||||
* followed by a PNG_HANDLE_* byte */
|
||||
#endif
|
||||
|
||||
/* New members added in libpng-1.0.3 */
|
||||
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||
png_byte rgb_to_gray_status;
|
||||
/* Added in libpng 1.5.5 to record setting of coefficients: */
|
||||
png_byte rgb_to_gray_coefficients_set;
|
||||
/* These were changed from png_byte in libpng-1.0.6 */
|
||||
png_uint_16 rgb_to_gray_red_coeff;
|
||||
png_uint_16 rgb_to_gray_green_coeff;
|
||||
png_uint_16 rgb_to_gray_blue_coeff;
|
||||
/* deleted in 1.5.5: rgb_to_gray_blue_coeff; */
|
||||
#endif
|
||||
|
||||
/* New member added in libpng-1.0.4 (renamed in 1.0.9) */
|
||||
#if defined(PNG_MNG_FEATURES_SUPPORTED) || \
|
||||
defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \
|
||||
defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED)
|
||||
#if defined(PNG_MNG_FEATURES_SUPPORTED)
|
||||
/* Changed from png_byte to png_uint_32 at version 1.2.0 */
|
||||
png_uint_32 mng_features_permitted;
|
||||
#endif
|
||||
@ -345,21 +477,41 @@ struct png_struct_def
|
||||
#endif
|
||||
|
||||
/* New member added in libpng-1.0.25 and 1.2.17 */
|
||||
#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
|
||||
/* Storage for unknown chunk that the library doesn't recognize. */
|
||||
#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
|
||||
/* Temporary storage for unknown chunk that the library doesn't recognize,
|
||||
* used while reading the chunk.
|
||||
*/
|
||||
png_unknown_chunk unknown_chunk;
|
||||
#endif
|
||||
|
||||
/* New members added in libpng-1.2.26 */
|
||||
/* New member added in libpng-1.2.26 */
|
||||
png_size_t old_big_row_buf_size;
|
||||
png_size_t old_prev_row_size;
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
/* New member added in libpng-1.2.30 */
|
||||
png_charp chunkdata; /* buffer for reading chunk data */
|
||||
png_bytep read_buffer; /* buffer for reading chunk data */
|
||||
png_alloc_size_t read_buffer_size; /* current size of the buffer */
|
||||
#endif
|
||||
#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
|
||||
uInt IDAT_read_size; /* limit on read buffer size for IDAT */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_IO_STATE_SUPPORTED
|
||||
/* New member added in libpng-1.4.0 */
|
||||
png_uint_32 io_state;
|
||||
#endif
|
||||
|
||||
/* New member added in libpng-1.5.6 */
|
||||
png_bytep big_prev_row;
|
||||
|
||||
/* New member added in libpng-1.5.7 */
|
||||
void (*read_filter[PNG_FILTER_VALUE_LAST-1])(png_row_infop row_info,
|
||||
png_bytep row, png_const_bytep prev_row);
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)
|
||||
png_colorspace colorspace;
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
#endif /* PNGSTRUCT_H */
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -29,8 +29,8 @@
|
||||
* However, the following notice accompanied the original version of this
|
||||
* file and, per its terms, should not be removed:
|
||||
*
|
||||
* Last changed in libpng 1.5.4 [July 7, 2011]
|
||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.15 [November 20, 2014]
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@ -46,7 +46,7 @@
|
||||
#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
|
||||
/* Turn on BGR-to-RGB mapping */
|
||||
void PNGAPI
|
||||
png_set_bgr(png_structp png_ptr)
|
||||
png_set_bgr(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_bgr");
|
||||
|
||||
@ -60,7 +60,7 @@ png_set_bgr(png_structp png_ptr)
|
||||
#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
|
||||
/* Turn on 16 bit byte swapping */
|
||||
void PNGAPI
|
||||
png_set_swap(png_structp png_ptr)
|
||||
png_set_swap(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_swap");
|
||||
|
||||
@ -75,7 +75,7 @@ png_set_swap(png_structp png_ptr)
|
||||
#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
|
||||
/* Turn on pixel packing */
|
||||
void PNGAPI
|
||||
png_set_packing(png_structp png_ptr)
|
||||
png_set_packing(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_packing");
|
||||
|
||||
@ -85,7 +85,9 @@ png_set_packing(png_structp png_ptr)
|
||||
if (png_ptr->bit_depth < 8)
|
||||
{
|
||||
png_ptr->transformations |= PNG_PACK;
|
||||
png_ptr->usr_bit_depth = 8;
|
||||
# ifdef PNG_WRITE_SUPPORTED
|
||||
png_ptr->usr_bit_depth = 8;
|
||||
# endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -93,7 +95,7 @@ png_set_packing(png_structp png_ptr)
|
||||
#if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED)
|
||||
/* Turn on packed pixel swapping */
|
||||
void PNGAPI
|
||||
png_set_packswap(png_structp png_ptr)
|
||||
png_set_packswap(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_packswap");
|
||||
|
||||
@ -107,7 +109,7 @@ png_set_packswap(png_structp png_ptr)
|
||||
|
||||
#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
|
||||
void PNGAPI
|
||||
png_set_shift(png_structp png_ptr, png_const_color_8p true_bits)
|
||||
png_set_shift(png_structrp png_ptr, png_const_color_8p true_bits)
|
||||
{
|
||||
png_debug(1, "in png_set_shift");
|
||||
|
||||
@ -122,11 +124,11 @@ png_set_shift(png_structp png_ptr, png_const_color_8p true_bits)
|
||||
#if defined(PNG_READ_INTERLACING_SUPPORTED) || \
|
||||
defined(PNG_WRITE_INTERLACING_SUPPORTED)
|
||||
int PNGAPI
|
||||
png_set_interlace_handling(png_structp png_ptr)
|
||||
png_set_interlace_handling(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_interlace handling");
|
||||
|
||||
if (png_ptr && png_ptr->interlaced)
|
||||
if (png_ptr != 0 && png_ptr->interlaced != 0)
|
||||
{
|
||||
png_ptr->transformations |= PNG_INTERLACE;
|
||||
return (7);
|
||||
@ -143,44 +145,91 @@ png_set_interlace_handling(png_structp png_ptr)
|
||||
* that don't like bytes as parameters.
|
||||
*/
|
||||
void PNGAPI
|
||||
png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc)
|
||||
png_set_filler(png_structrp png_ptr, png_uint_32 filler, int filler_loc)
|
||||
{
|
||||
png_debug(1, "in png_set_filler");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
/* In libpng 1.6 it is possible to determine whether this is a read or write
|
||||
* operation and therefore to do more checking here for a valid call.
|
||||
*/
|
||||
if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0)
|
||||
{
|
||||
# ifdef PNG_READ_FILLER_SUPPORTED
|
||||
/* On read png_set_filler is always valid, regardless of the base PNG
|
||||
* format, because other transformations can give a format where the
|
||||
* filler code can execute (basically an 8 or 16-bit component RGB or G
|
||||
* format.)
|
||||
*
|
||||
* NOTE: usr_channels is not used by the read code! (This has led to
|
||||
* confusion in the past.) The filler is only used in the read code.
|
||||
*/
|
||||
png_ptr->filler = (png_uint_16)filler;
|
||||
# else
|
||||
png_app_error(png_ptr, "png_set_filler not supported on read");
|
||||
PNG_UNUSED(filler) /* not used in the write case */
|
||||
return;
|
||||
# endif
|
||||
}
|
||||
|
||||
else /* write */
|
||||
{
|
||||
# ifdef PNG_WRITE_FILLER_SUPPORTED
|
||||
/* On write the usr_channels parameter must be set correctly at the
|
||||
* start to record the number of channels in the app-supplied data.
|
||||
*/
|
||||
switch (png_ptr->color_type)
|
||||
{
|
||||
case PNG_COLOR_TYPE_RGB:
|
||||
png_ptr->usr_channels = 4;
|
||||
break;
|
||||
|
||||
case PNG_COLOR_TYPE_GRAY:
|
||||
if (png_ptr->bit_depth >= 8)
|
||||
{
|
||||
png_ptr->usr_channels = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
/* There simply isn't any code in libpng to strip out bits
|
||||
* from bytes when the components are less than a byte in
|
||||
* size!
|
||||
*/
|
||||
png_app_error(png_ptr,
|
||||
"png_set_filler is invalid for low bit depth gray output");
|
||||
return;
|
||||
}
|
||||
|
||||
default:
|
||||
png_app_error(png_ptr,
|
||||
"png_set_filler: inappropriate color type");
|
||||
return;
|
||||
}
|
||||
# else
|
||||
png_app_error(png_ptr, "png_set_filler not supported on write");
|
||||
return;
|
||||
# endif
|
||||
}
|
||||
|
||||
/* Here on success - libpng supports the operation, set the transformation
|
||||
* and the flag to say where the filler channel is.
|
||||
*/
|
||||
png_ptr->transformations |= PNG_FILLER;
|
||||
png_ptr->filler = (png_uint_16)filler;
|
||||
|
||||
if (filler_loc == PNG_FILLER_AFTER)
|
||||
png_ptr->flags |= PNG_FLAG_FILLER_AFTER;
|
||||
|
||||
else
|
||||
png_ptr->flags &= ~PNG_FLAG_FILLER_AFTER;
|
||||
|
||||
/* This should probably go in the "do_read_filler" routine.
|
||||
* I attempted to do that in libpng-1.0.1a but that caused problems
|
||||
* so I restored it in libpng-1.0.2a
|
||||
*/
|
||||
|
||||
if (png_ptr->color_type == PNG_COLOR_TYPE_RGB)
|
||||
{
|
||||
png_ptr->usr_channels = 4;
|
||||
}
|
||||
|
||||
/* Also I added this in libpng-1.0.2a (what happens when we expand
|
||||
* a less-than-8-bit grayscale to GA?) */
|
||||
|
||||
if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY && png_ptr->bit_depth >= 8)
|
||||
{
|
||||
png_ptr->usr_channels = 2;
|
||||
}
|
||||
}
|
||||
|
||||
/* Added to libpng-1.2.7 */
|
||||
void PNGAPI
|
||||
png_set_add_alpha(png_structp png_ptr, png_uint_32 filler, int filler_loc)
|
||||
png_set_add_alpha(png_structrp png_ptr, png_uint_32 filler, int filler_loc)
|
||||
{
|
||||
png_debug(1, "in png_set_add_alpha");
|
||||
|
||||
@ -188,7 +237,9 @@ png_set_add_alpha(png_structp png_ptr, png_uint_32 filler, int filler_loc)
|
||||
return;
|
||||
|
||||
png_set_filler(png_ptr, filler, filler_loc);
|
||||
png_ptr->transformations |= PNG_ADD_ALPHA;
|
||||
/* The above may fail to do anything. */
|
||||
if ((png_ptr->transformations & PNG_FILLER) != 0)
|
||||
png_ptr->transformations |= PNG_ADD_ALPHA;
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -196,7 +247,7 @@ png_set_add_alpha(png_structp png_ptr, png_uint_32 filler, int filler_loc)
|
||||
#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \
|
||||
defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
|
||||
void PNGAPI
|
||||
png_set_swap_alpha(png_structp png_ptr)
|
||||
png_set_swap_alpha(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_swap_alpha");
|
||||
|
||||
@ -210,7 +261,7 @@ png_set_swap_alpha(png_structp png_ptr)
|
||||
#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \
|
||||
defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
|
||||
void PNGAPI
|
||||
png_set_invert_alpha(png_structp png_ptr)
|
||||
png_set_invert_alpha(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_invert_alpha");
|
||||
|
||||
@ -223,7 +274,7 @@ png_set_invert_alpha(png_structp png_ptr)
|
||||
|
||||
#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
|
||||
void PNGAPI
|
||||
png_set_invert_mono(png_structp png_ptr)
|
||||
png_set_invert_mono(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_invert_mono");
|
||||
|
||||
@ -304,9 +355,16 @@ png_do_swap(png_row_infop row_info, png_bytep row)
|
||||
|
||||
for (i = 0; i < istop; i++, rp += 2)
|
||||
{
|
||||
#ifdef PNG_BUILTIN_BSWAP16_SUPPORTED
|
||||
/* Feature added to libpng-1.6.11 for testing purposes, not
|
||||
* enabled by default.
|
||||
*/
|
||||
*(png_uint_16*)rp = __builtin_bswap16(*(png_uint_16*)rp);
|
||||
#else
|
||||
png_byte t = *rp;
|
||||
*rp = *(rp + 1);
|
||||
*(rp + 1) = t;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -448,7 +506,7 @@ png_do_packswap(png_row_infop row_info, png_bytep row)
|
||||
*rp = table[*rp];
|
||||
}
|
||||
}
|
||||
#endif /* PNG_READ_PACKSWAP_SUPPORTED or PNG_WRITE_PACKSWAP_SUPPORTED */
|
||||
#endif /* PACKSWAP || WRITE_PACKSWAP */
|
||||
|
||||
#if defined(PNG_WRITE_FILLER_SUPPORTED) || \
|
||||
defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
|
||||
@ -480,7 +538,7 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
|
||||
{
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
if (at_start) /* Skip initial filler */
|
||||
if (at_start != 0) /* Skip initial filler */
|
||||
++sp;
|
||||
else /* Skip initial channel and, for sp, the filler */
|
||||
sp += 2, ++dp;
|
||||
@ -494,7 +552,7 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
|
||||
|
||||
else if (row_info->bit_depth == 16)
|
||||
{
|
||||
if (at_start) /* Skip initial filler */
|
||||
if (at_start != 0) /* Skip initial filler */
|
||||
sp += 2;
|
||||
else /* Skip initial channel and, for sp, the filler */
|
||||
sp += 4, dp += 2;
|
||||
@ -520,7 +578,7 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
|
||||
{
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
if (at_start) /* Skip initial filler */
|
||||
if (at_start != 0) /* Skip initial filler */
|
||||
++sp;
|
||||
else /* Skip initial channels and, for sp, the filler */
|
||||
sp += 4, dp += 3;
|
||||
@ -534,7 +592,7 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
|
||||
|
||||
else if (row_info->bit_depth == 16)
|
||||
{
|
||||
if (at_start) /* Skip initial filler */
|
||||
if (at_start != 0) /* Skip initial filler */
|
||||
sp += 2;
|
||||
else /* Skip initial channels and, for sp, the filler */
|
||||
sp += 8, dp += 6;
|
||||
@ -575,7 +633,7 @@ png_do_bgr(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
png_debug(1, "in png_do_bgr");
|
||||
|
||||
if ((row_info->color_type & PNG_COLOR_MASK_COLOR))
|
||||
if ((row_info->color_type & PNG_COLOR_MASK_COLOR) != 0)
|
||||
{
|
||||
png_uint_32 row_width = row_info->width;
|
||||
if (row_info->bit_depth == 8)
|
||||
@ -645,19 +703,133 @@ png_do_bgr(png_row_infop row_info, png_bytep row)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif /* PNG_READ_BGR_SUPPORTED or PNG_WRITE_BGR_SUPPORTED */
|
||||
#endif /* READ_BGR || WRITE_BGR */
|
||||
|
||||
#if defined(PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED) || \
|
||||
defined(PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED)
|
||||
/* Added at libpng-1.5.10 */
|
||||
void /* PRIVATE */
|
||||
png_do_check_palette_indexes(png_structrp png_ptr, png_row_infop row_info)
|
||||
{
|
||||
if (png_ptr->num_palette < (1 << row_info->bit_depth) &&
|
||||
png_ptr->num_palette > 0) /* num_palette can be 0 in MNG files */
|
||||
{
|
||||
/* Calculations moved outside switch in an attempt to stop different
|
||||
* compiler warnings. 'padding' is in *bits* within the last byte, it is
|
||||
* an 'int' because pixel_depth becomes an 'int' in the expression below,
|
||||
* and this calculation is used because it avoids warnings that other
|
||||
* forms produced on either GCC or MSVC.
|
||||
*/
|
||||
int padding = (-row_info->pixel_depth * row_info->width) & 7;
|
||||
png_bytep rp = png_ptr->row_buf + row_info->rowbytes;
|
||||
|
||||
switch (row_info->bit_depth)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
/* in this case, all bytes must be 0 so we don't need
|
||||
* to unpack the pixels except for the rightmost one.
|
||||
*/
|
||||
for (; rp > png_ptr->row_buf; rp--)
|
||||
{
|
||||
if (*rp >> padding != 0)
|
||||
png_ptr->num_palette_max = 1;
|
||||
padding = 0;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 2:
|
||||
{
|
||||
for (; rp > png_ptr->row_buf; rp--)
|
||||
{
|
||||
int i = ((*rp >> padding) & 0x03);
|
||||
|
||||
if (i > png_ptr->num_palette_max)
|
||||
png_ptr->num_palette_max = i;
|
||||
|
||||
i = (((*rp >> padding) >> 2) & 0x03);
|
||||
|
||||
if (i > png_ptr->num_palette_max)
|
||||
png_ptr->num_palette_max = i;
|
||||
|
||||
i = (((*rp >> padding) >> 4) & 0x03);
|
||||
|
||||
if (i > png_ptr->num_palette_max)
|
||||
png_ptr->num_palette_max = i;
|
||||
|
||||
i = (((*rp >> padding) >> 6) & 0x03);
|
||||
|
||||
if (i > png_ptr->num_palette_max)
|
||||
png_ptr->num_palette_max = i;
|
||||
|
||||
padding = 0;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 4:
|
||||
{
|
||||
for (; rp > png_ptr->row_buf; rp--)
|
||||
{
|
||||
int i = ((*rp >> padding) & 0x0f);
|
||||
|
||||
if (i > png_ptr->num_palette_max)
|
||||
png_ptr->num_palette_max = i;
|
||||
|
||||
i = (((*rp >> padding) >> 4) & 0x0f);
|
||||
|
||||
if (i > png_ptr->num_palette_max)
|
||||
png_ptr->num_palette_max = i;
|
||||
|
||||
padding = 0;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 8:
|
||||
{
|
||||
for (; rp > png_ptr->row_buf; rp--)
|
||||
{
|
||||
if (*rp > png_ptr->num_palette_max)
|
||||
png_ptr->num_palette_max = (int) *rp;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* CHECK_FOR_INVALID_INDEX */
|
||||
|
||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
|
||||
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||
#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_user_transform_info(png_structp png_ptr, png_voidp
|
||||
png_set_user_transform_info(png_structrp png_ptr, png_voidp
|
||||
user_transform_ptr, int user_transform_depth, int user_transform_channels)
|
||||
{
|
||||
png_debug(1, "in png_set_user_transform_info");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
|
||||
if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0 &&
|
||||
(png_ptr->flags & PNG_FLAG_ROW_INIT) != 0)
|
||||
{
|
||||
png_app_error(png_ptr,
|
||||
"info change after png_start_read_image or png_read_update_info");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
png_ptr->user_transform_ptr = user_transform_ptr;
|
||||
png_ptr->user_transform_depth = (png_byte)user_transform_depth;
|
||||
png_ptr->user_transform_channels = (png_byte)user_transform_channels;
|
||||
@ -671,20 +843,20 @@ png_set_user_transform_info(png_structp png_ptr, png_voidp
|
||||
*/
|
||||
#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
|
||||
png_voidp PNGAPI
|
||||
png_get_user_transform_ptr(png_const_structp png_ptr)
|
||||
png_get_user_transform_ptr(png_const_structrp png_ptr)
|
||||
{
|
||||
if (png_ptr == NULL)
|
||||
return (NULL);
|
||||
|
||||
return ((png_voidp)png_ptr->user_transform_ptr);
|
||||
return png_ptr->user_transform_ptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_USER_TRANSFORM_INFO_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_current_row_number(png_const_structp png_ptr)
|
||||
png_get_current_row_number(png_const_structrp png_ptr)
|
||||
{
|
||||
/* See the comments in png.h - this is the sub-image row when reading and
|
||||
/* See the comments in png.h - this is the sub-image row when reading an
|
||||
* interlaced image.
|
||||
*/
|
||||
if (png_ptr != NULL)
|
||||
@ -694,13 +866,12 @@ png_get_current_row_number(png_const_structp png_ptr)
|
||||
}
|
||||
|
||||
png_byte PNGAPI
|
||||
png_get_current_pass_number(png_const_structp png_ptr)
|
||||
png_get_current_pass_number(png_const_structrp png_ptr)
|
||||
{
|
||||
if (png_ptr != NULL)
|
||||
return png_ptr->pass;
|
||||
return 8; /* invalid */
|
||||
}
|
||||
#endif /* PNG_USER_TRANSFORM_INFO_SUPPORTED */
|
||||
#endif /* PNG_READ_USER_TRANSFORM_SUPPORTED ||
|
||||
PNG_WRITE_USER_TRANSFORM_SUPPORTED */
|
||||
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
||||
#endif /* USER_TRANSFORM_INFO */
|
||||
#endif /* READ_USER_TRANSFORM || WRITE_USER_TRANSFORM */
|
||||
#endif /* READ || WRITE */
|
||||
|
@ -29,8 +29,8 @@
|
||||
* However, the following notice accompanied the original version of this
|
||||
* file and, per its terms, should not be removed:
|
||||
*
|
||||
* Last changed in libpng 1.5.0 [January 6, 2011]
|
||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.15 [November 20, 2014]
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@ -58,11 +58,12 @@
|
||||
*/
|
||||
|
||||
void /* PRIVATE */
|
||||
png_write_data(png_structp png_ptr, png_const_bytep data, png_size_t length)
|
||||
png_write_data(png_structrp png_ptr, png_const_bytep data, png_size_t length)
|
||||
{
|
||||
/* NOTE: write_data_fn must not change the buffer! */
|
||||
if (png_ptr->write_data_fn != NULL )
|
||||
(*(png_ptr->write_data_fn))(png_ptr, (png_bytep)data, length);
|
||||
(*(png_ptr->write_data_fn))(png_ptr, png_constcast(png_bytep,data),
|
||||
length);
|
||||
|
||||
else
|
||||
png_error(png_ptr, "Call to NULL write function");
|
||||
@ -74,7 +75,6 @@ png_write_data(png_structp png_ptr, png_const_bytep data, png_size_t length)
|
||||
* write_data function and use it at run time with png_set_write_fn(), rather
|
||||
* than changing the library.
|
||||
*/
|
||||
#ifndef USE_FAR_KEYWORD
|
||||
void PNGCBAPI
|
||||
png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
@ -88,64 +88,6 @@ png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
if (check != length)
|
||||
png_error(png_ptr, "Write Error");
|
||||
}
|
||||
#else
|
||||
/* This is the model-independent version. Since the standard I/O library
|
||||
* can't handle far buffers in the medium and small models, we have to copy
|
||||
* the data.
|
||||
*/
|
||||
|
||||
#define NEAR_BUF_SIZE 1024
|
||||
#define MIN(a,b) (a <= b ? a : b)
|
||||
|
||||
void PNGCBAPI
|
||||
png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
png_uint_32 check;
|
||||
png_byte *near_data; /* Needs to be "png_byte *" instead of "png_bytep" */
|
||||
png_FILE_p io_ptr;
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
/* Check if data really is near. If so, use usual code. */
|
||||
near_data = (png_byte *)CVT_PTR_NOCHECK(data);
|
||||
io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr);
|
||||
|
||||
if ((png_bytep)near_data == data)
|
||||
{
|
||||
check = fwrite(near_data, 1, length, io_ptr);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
png_byte buf[NEAR_BUF_SIZE];
|
||||
png_size_t written, remaining, err;
|
||||
check = 0;
|
||||
remaining = length;
|
||||
|
||||
do
|
||||
{
|
||||
written = MIN(NEAR_BUF_SIZE, remaining);
|
||||
png_memcpy(buf, data, written); /* Copy far buffer to near buffer */
|
||||
err = fwrite(buf, 1, written, io_ptr);
|
||||
|
||||
if (err != written)
|
||||
break;
|
||||
|
||||
else
|
||||
check += err;
|
||||
|
||||
data += written;
|
||||
remaining -= written;
|
||||
}
|
||||
while (remaining != 0);
|
||||
}
|
||||
|
||||
if (check != length)
|
||||
png_error(png_ptr, "Write Error");
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* This function is called to output any data pending writing (normally
|
||||
@ -154,7 +96,7 @@ png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
*/
|
||||
#ifdef PNG_WRITE_FLUSH_SUPPORTED
|
||||
void /* PRIVATE */
|
||||
png_flush(png_structp png_ptr)
|
||||
png_flush(png_structrp png_ptr)
|
||||
{
|
||||
if (png_ptr->output_flush_fn != NULL)
|
||||
(*(png_ptr->output_flush_fn))(png_ptr);
|
||||
@ -169,7 +111,7 @@ png_default_flush(png_structp png_ptr)
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr));
|
||||
io_ptr = png_voidcast(png_FILE_p, (png_ptr->io_ptr));
|
||||
fflush(io_ptr);
|
||||
}
|
||||
# endif
|
||||
@ -205,7 +147,7 @@ png_default_flush(png_structp png_ptr)
|
||||
* *FILE structure.
|
||||
*/
|
||||
void PNGAPI
|
||||
png_set_write_fn(png_structp png_ptr, png_voidp io_ptr,
|
||||
png_set_write_fn(png_structrp png_ptr, png_voidp io_ptr,
|
||||
png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)
|
||||
{
|
||||
if (png_ptr == NULL)
|
||||
@ -235,8 +177,11 @@ png_set_write_fn(png_structp png_ptr, png_voidp io_ptr,
|
||||
# else
|
||||
png_ptr->output_flush_fn = output_flush_fn;
|
||||
# endif
|
||||
#endif /* PNG_WRITE_FLUSH_SUPPORTED */
|
||||
#else
|
||||
PNG_UNUSED(output_flush_fn)
|
||||
#endif /* WRITE_FLUSH */
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
/* It is an error to read while writing a png file */
|
||||
if (png_ptr->read_data_fn != NULL)
|
||||
{
|
||||
@ -246,37 +191,6 @@ png_set_write_fn(png_structp png_ptr, png_voidp io_ptr,
|
||||
"Can't set both read_data_fn and write_data_fn in the"
|
||||
" same structure");
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef USE_FAR_KEYWORD
|
||||
# ifdef _MSC_VER
|
||||
void *png_far_to_near(png_structp png_ptr, png_voidp ptr, int check)
|
||||
{
|
||||
void *near_ptr;
|
||||
void FAR *far_ptr;
|
||||
FP_OFF(near_ptr) = FP_OFF(ptr);
|
||||
far_ptr = (void FAR *)near_ptr;
|
||||
|
||||
if (check != 0)
|
||||
if (FP_SEG(ptr) != FP_SEG(far_ptr))
|
||||
png_error(png_ptr, "segment lost in conversion");
|
||||
|
||||
return(near_ptr);
|
||||
}
|
||||
# else
|
||||
void *png_far_to_near(png_structp png_ptr, png_voidp ptr, int check)
|
||||
{
|
||||
void *near_ptr;
|
||||
void FAR *far_ptr;
|
||||
near_ptr = (void FAR *)ptr;
|
||||
far_ptr = (void FAR *)near_ptr;
|
||||
|
||||
if (check != 0)
|
||||
if (far_ptr != ptr)
|
||||
png_error(png_ptr, "segment lost in conversion");
|
||||
|
||||
return(near_ptr);
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
#endif /* PNG_WRITE_SUPPORTED */
|
||||
}
|
||||
#endif /* WRITE */
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -29,8 +29,8 @@
|
||||
* However, the following notice accompanied the original version of this
|
||||
* file and, per its terms, should not be removed:
|
||||
*
|
||||
* Last changed in libpng 1.5.4 [July 7, 2011]
|
||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.15 [November 20, 2014]
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@ -42,90 +42,14 @@
|
||||
#include "pngpriv.h"
|
||||
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
|
||||
#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
|
||||
/* Transform the data according to the user's wishes. The order of
|
||||
* transformations is significant.
|
||||
*/
|
||||
void /* PRIVATE */
|
||||
png_do_write_transformations(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_do_write_transformations");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_USER_TRANSFORM)
|
||||
if (png_ptr->write_user_transform_fn != NULL)
|
||||
(*(png_ptr->write_user_transform_fn)) /* User write transform
|
||||
function */
|
||||
(png_ptr, /* png_ptr */
|
||||
&(png_ptr->row_info), /* row_info: */
|
||||
/* png_uint_32 width; width of row */
|
||||
/* png_size_t rowbytes; number of bytes in row */
|
||||
/* png_byte color_type; color type of pixels */
|
||||
/* png_byte bit_depth; bit depth of samples */
|
||||
/* png_byte channels; number of channels (1-4) */
|
||||
/* png_byte pixel_depth; bits per pixel (depth*channels) */
|
||||
png_ptr->row_buf + 1); /* start of pixel data for row */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_FILLER_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_FILLER)
|
||||
png_do_strip_channel(&(png_ptr->row_info), png_ptr->row_buf + 1,
|
||||
!(png_ptr->flags & PNG_FLAG_FILLER_AFTER));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_PACKSWAP_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_PACKSWAP)
|
||||
png_do_packswap(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_PACK_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_PACK)
|
||||
png_do_pack(&(png_ptr->row_info), png_ptr->row_buf + 1,
|
||||
(png_uint_32)png_ptr->bit_depth);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_SWAP_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_SWAP_BYTES)
|
||||
png_do_swap(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_SHIFT_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_SHIFT)
|
||||
png_do_shift(&(png_ptr->row_info), png_ptr->row_buf + 1,
|
||||
&(png_ptr->shift));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_SWAP_ALPHA)
|
||||
png_do_write_swap_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_INVERT_ALPHA)
|
||||
png_do_write_invert_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_BGR_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_BGR)
|
||||
png_do_bgr(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_INVERT_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_INVERT_MONO)
|
||||
png_do_invert(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef PNG_WRITE_PACK_SUPPORTED
|
||||
/* Pack pixels into bytes. Pass the true bit depth in bit_depth. The
|
||||
* row_info bit depth should be 8 (one pixel per byte). The channels
|
||||
* should be 1 (this only happens on grayscale and paletted images).
|
||||
*/
|
||||
void /* PRIVATE */
|
||||
static void
|
||||
png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
|
||||
{
|
||||
png_debug(1, "in png_do_pack");
|
||||
@ -270,7 +194,7 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
|
||||
* would pass 3 as bit_depth, and this routine would translate the
|
||||
* data to 0 to 15.
|
||||
*/
|
||||
void /* PRIVATE */
|
||||
static void
|
||||
png_do_shift(png_row_infop row_info, png_bytep row,
|
||||
png_const_color_8p bit_depth)
|
||||
{
|
||||
@ -281,7 +205,7 @@ png_do_shift(png_row_infop row_info, png_bytep row,
|
||||
int shift_start[4], shift_dec[4];
|
||||
int channels = 0;
|
||||
|
||||
if (row_info->color_type & PNG_COLOR_MASK_COLOR)
|
||||
if ((row_info->color_type & PNG_COLOR_MASK_COLOR) != 0)
|
||||
{
|
||||
shift_start[channels] = row_info->bit_depth - bit_depth->red;
|
||||
shift_dec[channels] = bit_depth->red;
|
||||
@ -303,7 +227,7 @@ png_do_shift(png_row_infop row_info, png_bytep row,
|
||||
channels++;
|
||||
}
|
||||
|
||||
if (row_info->color_type & PNG_COLOR_MASK_ALPHA)
|
||||
if ((row_info->color_type & PNG_COLOR_MASK_ALPHA) != 0)
|
||||
{
|
||||
shift_start[channels] = row_info->bit_depth - bit_depth->alpha;
|
||||
shift_dec[channels] = bit_depth->alpha;
|
||||
@ -315,7 +239,7 @@ png_do_shift(png_row_infop row_info, png_bytep row,
|
||||
{
|
||||
png_bytep bp = row;
|
||||
png_size_t i;
|
||||
png_byte mask;
|
||||
unsigned int mask;
|
||||
png_size_t row_bytes = row_info->rowbytes;
|
||||
|
||||
if (bit_depth->gray == 1 && row_info->bit_depth == 2)
|
||||
@ -329,20 +253,22 @@ png_do_shift(png_row_infop row_info, png_bytep row,
|
||||
|
||||
for (i = 0; i < row_bytes; i++, bp++)
|
||||
{
|
||||
png_uint_16 v;
|
||||
int j;
|
||||
unsigned int v, out;
|
||||
|
||||
v = *bp;
|
||||
*bp = 0;
|
||||
out = 0;
|
||||
|
||||
for (j = shift_start[0]; j > -shift_dec[0]; j -= shift_dec[0])
|
||||
{
|
||||
if (j > 0)
|
||||
*bp |= (png_byte)((v << j) & 0xff);
|
||||
out |= v << j;
|
||||
|
||||
else
|
||||
*bp |= (png_byte)((v >> (-j)) & mask);
|
||||
out |= (v >> (-j)) & mask;
|
||||
}
|
||||
|
||||
*bp = (png_byte)(out & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
@ -355,21 +281,23 @@ png_do_shift(png_row_infop row_info, png_bytep row,
|
||||
for (i = 0; i < istop; i++, bp++)
|
||||
{
|
||||
|
||||
png_uint_16 v;
|
||||
const unsigned int c = i%channels;
|
||||
int j;
|
||||
int c = (int)(i%channels);
|
||||
unsigned int v, out;
|
||||
|
||||
v = *bp;
|
||||
*bp = 0;
|
||||
out = 0;
|
||||
|
||||
for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c])
|
||||
{
|
||||
if (j > 0)
|
||||
*bp |= (png_byte)((v << j) & 0xff);
|
||||
out |= v << j;
|
||||
|
||||
else
|
||||
*bp |= (png_byte)((v >> (-j)) & 0xff);
|
||||
out |= v >> (-j);
|
||||
}
|
||||
|
||||
*bp = (png_byte)(out & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
@ -381,22 +309,22 @@ png_do_shift(png_row_infop row_info, png_bytep row,
|
||||
|
||||
for (bp = row, i = 0; i < istop; i++)
|
||||
{
|
||||
int c = (int)(i%channels);
|
||||
png_uint_16 value, v;
|
||||
const unsigned int c = i%channels;
|
||||
int j;
|
||||
unsigned int value, v;
|
||||
|
||||
v = (png_uint_16)(((png_uint_16)(*bp) << 8) + *(bp + 1));
|
||||
v = png_get_uint_16(bp);
|
||||
value = 0;
|
||||
|
||||
for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c])
|
||||
{
|
||||
if (j > 0)
|
||||
value |= (png_uint_16)((v << j) & (png_uint_16)0xffff);
|
||||
value |= v << j;
|
||||
|
||||
else
|
||||
value |= (png_uint_16)((v >> (-j)) & (png_uint_16)0xffff);
|
||||
value |= v >> (-j);
|
||||
}
|
||||
*bp++ = (png_byte)(value >> 8);
|
||||
*bp++ = (png_byte)((value >> 8) & 0xff);
|
||||
*bp++ = (png_byte)(value & 0xff);
|
||||
}
|
||||
}
|
||||
@ -405,7 +333,7 @@ png_do_shift(png_row_infop row_info, png_bytep row,
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED
|
||||
void /* PRIVATE */
|
||||
static void
|
||||
png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
png_debug(1, "in png_do_write_swap_alpha");
|
||||
@ -453,7 +381,7 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
|
||||
*(dp++) = save[1];
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WRITE_16BIT_SUPPORTED */
|
||||
#endif /* WRITE_16BIT */
|
||||
}
|
||||
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
|
||||
@ -492,14 +420,14 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
|
||||
*(dp++) = save[1];
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WRITE_16BIT_SUPPORTED */
|
||||
#endif /* WRITE_16BIT */
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
|
||||
void /* PRIVATE */
|
||||
static void
|
||||
png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
png_debug(1, "in png_do_write_invert_alpha");
|
||||
@ -549,7 +477,7 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||
*(dp++) = (png_byte)(255 - *(sp++));
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WRITE_16BIT_SUPPORTED */
|
||||
#endif /* WRITE_16BIT */
|
||||
}
|
||||
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
|
||||
@ -587,75 +515,88 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||
*(dp++) = (png_byte)(255 - *(sp++));
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WRITE_16BIT_SUPPORTED */
|
||||
#endif /* WRITE_16BIT */
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */
|
||||
|
||||
#ifdef PNG_MNG_FEATURES_SUPPORTED
|
||||
/* Undoes intrapixel differencing */
|
||||
/* Transform the data according to the user's wishes. The order of
|
||||
* transformations is significant.
|
||||
*/
|
||||
void /* PRIVATE */
|
||||
png_do_write_intrapixel(png_row_infop row_info, png_bytep row)
|
||||
png_do_write_transformations(png_structrp png_ptr, png_row_infop row_info)
|
||||
{
|
||||
png_debug(1, "in png_do_write_intrapixel");
|
||||
png_debug(1, "in png_do_write_transformations");
|
||||
|
||||
if ((row_info->color_type & PNG_COLOR_MASK_COLOR))
|
||||
{
|
||||
int bytes_per_pixel;
|
||||
png_uint_32 row_width = row_info->width;
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
png_bytep rp;
|
||||
png_uint_32 i;
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
if (row_info->color_type == PNG_COLOR_TYPE_RGB)
|
||||
bytes_per_pixel = 3;
|
||||
#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_USER_TRANSFORM) != 0)
|
||||
if (png_ptr->write_user_transform_fn != NULL)
|
||||
(*(png_ptr->write_user_transform_fn)) /* User write transform
|
||||
function */
|
||||
(png_ptr, /* png_ptr */
|
||||
row_info, /* row_info: */
|
||||
/* png_uint_32 width; width of row */
|
||||
/* png_size_t rowbytes; number of bytes in row */
|
||||
/* png_byte color_type; color type of pixels */
|
||||
/* png_byte bit_depth; bit depth of samples */
|
||||
/* png_byte channels; number of channels (1-4) */
|
||||
/* png_byte pixel_depth; bits per pixel (depth*channels) */
|
||||
png_ptr->row_buf + 1); /* start of pixel data for row */
|
||||
#endif
|
||||
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||
bytes_per_pixel = 4;
|
||||
#ifdef PNG_WRITE_FILLER_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_FILLER) != 0)
|
||||
png_do_strip_channel(row_info, png_ptr->row_buf + 1,
|
||||
!(png_ptr->flags & PNG_FLAG_FILLER_AFTER));
|
||||
#endif
|
||||
|
||||
else
|
||||
return;
|
||||
#ifdef PNG_WRITE_PACKSWAP_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_PACKSWAP) != 0)
|
||||
png_do_packswap(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)
|
||||
{
|
||||
*(rp) = (png_byte)((*rp - *(rp + 1)) & 0xff);
|
||||
*(rp + 2) = (png_byte)((*(rp + 2) - *(rp + 1)) & 0xff);
|
||||
}
|
||||
}
|
||||
#ifdef PNG_WRITE_PACK_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_PACK) != 0)
|
||||
png_do_pack(row_info, png_ptr->row_buf + 1,
|
||||
(png_uint_32)png_ptr->bit_depth);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_16BIT_SUPPORTED
|
||||
else if (row_info->bit_depth == 16)
|
||||
{
|
||||
png_bytep rp;
|
||||
png_uint_32 i;
|
||||
#ifdef PNG_WRITE_SWAP_SUPPORTED
|
||||
# ifdef PNG_16BIT_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_SWAP_BYTES) != 0)
|
||||
png_do_swap(row_info, png_ptr->row_buf + 1);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
if (row_info->color_type == PNG_COLOR_TYPE_RGB)
|
||||
bytes_per_pixel = 6;
|
||||
#ifdef PNG_WRITE_SHIFT_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_SHIFT) != 0)
|
||||
png_do_shift(row_info, png_ptr->row_buf + 1,
|
||||
&(png_ptr->shift));
|
||||
#endif
|
||||
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||
bytes_per_pixel = 8;
|
||||
#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_SWAP_ALPHA) != 0)
|
||||
png_do_write_swap_alpha(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
else
|
||||
return;
|
||||
#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_INVERT_ALPHA) != 0)
|
||||
png_do_write_invert_alpha(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)
|
||||
{
|
||||
png_uint_32 s0 = (*(rp ) << 8) | *(rp + 1);
|
||||
png_uint_32 s1 = (*(rp + 2) << 8) | *(rp + 3);
|
||||
png_uint_32 s2 = (*(rp + 4) << 8) | *(rp + 5);
|
||||
png_uint_32 red = (png_uint_32)((s0 - s1) & 0xffffL);
|
||||
png_uint_32 blue = (png_uint_32)((s2 - s1) & 0xffffL);
|
||||
*(rp ) = (png_byte)((red >> 8) & 0xff);
|
||||
*(rp + 1) = (png_byte)(red & 0xff);
|
||||
*(rp + 4) = (png_byte)((blue >> 8) & 0xff);
|
||||
*(rp + 5) = (png_byte)(blue & 0xff);
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WRITE_16BIT_SUPPORTED */
|
||||
}
|
||||
#ifdef PNG_WRITE_BGR_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_BGR) != 0)
|
||||
png_do_bgr(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_INVERT_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_INVERT_MONO) != 0)
|
||||
png_do_invert(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
}
|
||||
#endif /* PNG_MNG_FEATURES_SUPPORTED */
|
||||
#endif /* PNG_WRITE_SUPPORTED */
|
||||
#endif /* WRITE_TRANSFORMS */
|
||||
#endif /* WRITE */
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -29,6 +29,7 @@ import java.awt.peer.FileDialogPeer;
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
import sun.awt.AWTAccessor;
|
||||
import sun.misc.ManagedLocalsThread;
|
||||
|
||||
/**
|
||||
* FileDialogPeer for the GtkFileChooser.
|
||||
@ -111,13 +112,16 @@ final class GtkFileDialogPeer extends XDialogPeer implements FileDialogPeer {
|
||||
XToolkit.awtLock();
|
||||
try {
|
||||
if (b) {
|
||||
Thread t = new Thread() {
|
||||
public void run() {
|
||||
showNativeDialog();
|
||||
fd.setVisible(false);
|
||||
}
|
||||
Runnable task = () -> {
|
||||
showNativeDialog();
|
||||
fd.setVisible(false);
|
||||
};
|
||||
t.start();
|
||||
if (System.getSecurityManager() == null) {
|
||||
new Thread(task).start();
|
||||
} else {
|
||||
new ManagedLocalsThread(task).start();
|
||||
}
|
||||
|
||||
} else {
|
||||
quit();
|
||||
fd.setVisible(false);
|
||||
|
@ -29,6 +29,9 @@ import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.peer.TrayIconPeer;
|
||||
import sun.awt.*;
|
||||
import sun.misc.InnocuousThread;
|
||||
import sun.misc.ManagedLocalsThread;
|
||||
|
||||
import java.awt.image.*;
|
||||
import java.text.BreakIterator;
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
@ -338,7 +341,7 @@ public abstract class InfoWindow extends Window {
|
||||
lineLabels[i].setBackground(Color.white);
|
||||
}
|
||||
|
||||
displayer.start();
|
||||
displayer.thread.start();
|
||||
}
|
||||
|
||||
public void display(String caption, String text, String messageType) {
|
||||
@ -415,7 +418,7 @@ public abstract class InfoWindow extends Window {
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
displayer.interrupt();
|
||||
displayer.thread.interrupt();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@ -444,16 +447,23 @@ public abstract class InfoWindow extends Window {
|
||||
}
|
||||
}
|
||||
|
||||
private class Displayer extends Thread {
|
||||
private class Displayer implements Runnable {
|
||||
final int MAX_CONCURRENT_MSGS = 10;
|
||||
|
||||
ArrayBlockingQueue<Message> messageQueue = new ArrayBlockingQueue<Message>(MAX_CONCURRENT_MSGS);
|
||||
boolean isDisplayed;
|
||||
final Thread thread;
|
||||
|
||||
Displayer() {
|
||||
setDaemon(true);
|
||||
if (System.getSecurityManager() == null) {
|
||||
this.thread = new Thread(this);
|
||||
} else {
|
||||
this.thread = new ManagedLocalsThread(this);
|
||||
}
|
||||
this.thread.setDaemon(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while (true) {
|
||||
Message msg = null;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user