From d51dc1ff2dbd920c6488af4380b8064c9b6a7b4c Mon Sep 17 00:00:00 2001
From: Good Guy <good1.2guy@gmail.com>
Date: Tue, 29 Aug 2023 20:20:10 -0600
Subject: [PATCH] Credit Andrew - rest of fix for Arch (and termux) which
 includes thirdparty/Makefile

---
 cinelerra-5.1/cinelerra/filepng.C  | 1 +
 cinelerra-5.1/cinelerra/filetga.C  | 2 ++
 cinelerra-5.1/cinelerra/filetiff.C | 3 +++
 cinelerra-5.1/thirdparty/Makefile  | 2 ++
 4 files changed, 8 insertions(+)

diff --git a/cinelerra-5.1/cinelerra/filepng.C b/cinelerra-5.1/cinelerra/filepng.C
index 2386068b..e79c45d5 100644
--- a/cinelerra-5.1/cinelerra/filepng.C
+++ b/cinelerra-5.1/cinelerra/filepng.C
@@ -259,6 +259,7 @@ int FilePNG::read_frame(VFrame *output, VFrame *input)
 
 	//printf("FilePNG::read_frame 1 %d %d\n", native_cmodel, output->get_color_model());
 	png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0);
+	if(!png_ptr) return 0;
 	info_ptr = png_create_info_struct(png_ptr);
 	png_set_read_fn(png_ptr, input, (png_rw_ptr)read_function);
 	png_read_info(png_ptr, info_ptr);
diff --git a/cinelerra-5.1/cinelerra/filetga.C b/cinelerra-5.1/cinelerra/filetga.C
index df9a56ee..0bff2e18 100644
--- a/cinelerra-5.1/cinelerra/filetga.C
+++ b/cinelerra-5.1/cinelerra/filetga.C
@@ -337,6 +337,8 @@ void FileTGA::read_tga(Asset *asset, VFrame *frame, VFrame *data, VFrame* &temp)
 		case 24:
 			source_cmodel = BC_RGB888;
 			break;
+		default:
+			return;
 	}
 
 // Read image
diff --git a/cinelerra-5.1/cinelerra/filetiff.C b/cinelerra-5.1/cinelerra/filetiff.C
index 31a4bb7b..fc24b384 100644
--- a/cinelerra-5.1/cinelerra/filetiff.C
+++ b/cinelerra-5.1/cinelerra/filetiff.C
@@ -323,6 +323,9 @@ int FileTIFF::read_frame(VFrame *output, VFrame *input)
 	    tiff_mmap,
 		tiff_unmap);
 
+	if(!stream)
+	return 0;
+
 // This loads the original TIFF data into each scanline of the output frame,
 // assuming the output scanlines are bigger than the input scanlines.
 // Then it expands the input data in reverse to fill the row.
diff --git a/cinelerra-5.1/thirdparty/Makefile b/cinelerra-5.1/thirdparty/Makefile
index 8a5e5131..32c9372f 100644
--- a/cinelerra-5.1/thirdparty/Makefile
+++ b/cinelerra-5.1/thirdparty/Makefile
@@ -253,6 +253,8 @@ openexr.cfg_vars?=true; \#
 openexr.mak_vars?=true; \#
 opus.cfg_params?= --disable-extra-programs
 speech_tools.mak_params?=-j1
+tiff.ldflags?="$(call ld_path,libjpeg,build)"
+tiff.cflags?="$(call lnc_path,libjpeg)"
 tiff.cfg_vars+=LIBS+=" -lpthread"; autoreconf -ifv -I m4 && automake -caf;
 tiff.cfg_params+= --disable-libdeflate --disable-lerc --enable-shared=no --disable-zstd $(call if_pkg,libwebp,\
  --with-webp-include-dir=$(call pkg_incl,libwebp)\
-- 
2.26.2