tjexample.c: Fix mem leak if tjTransform() fails
Fixes #479
diff --git a/LICENSE.md b/LICENSE.md
index 25b38d9..a1cdad5 100644
--- a/LICENSE.md
+++ b/LICENSE.md
@@ -91,7 +91,7 @@
The Modified (3-clause) BSD License
===================================
-Copyright (C)2009-2020 D. R. Commander. All Rights Reserved.<br>
+Copyright (C)2009-2021 D. R. Commander. All Rights Reserved.<br>
Copyright (C)2015 Viktor Szathmáry. All Rights Reserved.
Redistribution and use in source and binary forms, with or without
diff --git a/jversion.h b/jversion.h
index d1d94f5..2ab534a 100644
--- a/jversion.h
+++ b/jversion.h
@@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-2020, Thomas G. Lane, Guido Vollbeding.
* libjpeg-turbo Modifications:
- * Copyright (C) 2010, 2012-2020, D. R. Commander.
+ * Copyright (C) 2010, 2012-2021, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -37,7 +37,7 @@
*/
#define JCOPYRIGHT \
- "Copyright (C) 2009-2020 D. R. Commander\n" \
+ "Copyright (C) 2009-2021 D. R. Commander\n" \
"Copyright (C) 2015, 2020 Google, Inc.\n" \
"Copyright (C) 2019-2020 Arm Limited\n" \
"Copyright (C) 2015-2016, 2018 Matthieu Darbois\n" \
@@ -51,4 +51,4 @@
"Copyright (C) 1991-2020 Thomas G. Lane, Guido Vollbeding"
#define JCOPYRIGHT_SHORT \
- "Copyright (C) 1991-2020 The libjpeg-turbo Project and many others"
+ "Copyright (C) 1991-2021 The libjpeg-turbo Project and many others"
diff --git a/tjexample.c b/tjexample.c
index ef32c93..a9cd865 100644
--- a/tjexample.c
+++ b/tjexample.c
@@ -1,6 +1,6 @@
/*
- * Copyright (C)2011-2012, 2014-2015, 2017, 2019 D. R. Commander.
- * All Rights Reserved.
+ * Copyright (C)2011-2012, 2014-2015, 2017, 2019, 2021 D. R. Commander.
+ * All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -288,8 +288,10 @@
THROW_TJ("initializing transformer");
xform.options |= TJXOPT_TRIM;
if (tjTransform(tjInstance, jpegBuf, jpegSize, 1, &dstBuf, &dstSize,
- &xform, flags) < 0)
+ &xform, flags) < 0) {
+ tjFree(dstBuf);
THROW_TJ("transforming input image");
+ }
tjFree(jpegBuf);
jpegBuf = dstBuf;
jpegSize = dstSize;