mirror of
https://github.com/termux-pacman/termux-packages.git
synced 2026-01-08 20:03:20 +00:00
fix(main/jpegoptim): Disable fdsan to fix running with multiple threads
This fixes the following runtime error. jpegoptim -w6 image.jpg image.jpg 512x512 24bit N JFIF [OK] 62476 --> 62476 bytes (0.00%), skipped. fdsan: attempted to close file descriptor 3, expected to be unowned, actually owned by FILE* 0x7d48447888 Aborted
This commit is contained in:
@@ -3,6 +3,7 @@ TERMUX_PKG_DESCRIPTION="JPEG optimizer that recompresses image files to a smalle
|
||||
TERMUX_PKG_LICENSE="GPL-3.0"
|
||||
TERMUX_PKG_MAINTAINER="@termux"
|
||||
TERMUX_PKG_VERSION="1.5.5"
|
||||
TERMUX_PKG_REVISION=1
|
||||
TERMUX_PKG_SRCURL=https://github.com/tjko/jpegoptim/archive/refs/tags/v${TERMUX_PKG_VERSION}.tar.gz
|
||||
TERMUX_PKG_SHA256=90a309d1c092de358bb411d702281ac3039b489d03adb0bc3c4ef04cf0067d38
|
||||
TERMUX_PKG_AUTO_UPDATE=true
|
||||
|
||||
29
packages/jpegoptim/disable-fdsan.patch
Normal file
29
packages/jpegoptim/disable-fdsan.patch
Normal file
@@ -0,0 +1,29 @@
|
||||
--- a/jpegoptim.c
|
||||
+++ b/jpegoptim.c
|
||||
@@ -1216,10 +1216,26 @@
|
||||
}
|
||||
#endif
|
||||
|
||||
+#include <android/fdsan.h>
|
||||
+#include <dlfcn.h>
|
||||
+
|
||||
+static inline void termux_disable_fdsan() {
|
||||
+ // For Android 11+.
|
||||
+ void *lib_handle = dlopen("libc.so", RTLD_LAZY);
|
||||
+ if (lib_handle) {
|
||||
+ void (*set_fdsan_error_level)(enum android_fdsan_error_level newlevel) = dlsym(lib_handle, "android_fdsan_set_error_level");
|
||||
+ if (set_fdsan_error_level) {
|
||||
+ set_fdsan_error_level(ANDROID_FDSAN_ERROR_LEVEL_DISABLED);
|
||||
+ }
|
||||
+ dlclose(lib_handle);
|
||||
+ }
|
||||
+}
|
||||
|
||||
/****************************************************************************/
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
+ termux_disable_fdsan();
|
||||
+
|
||||
struct stat file_stat;
|
||||
char tmpfilename[MAXPATHLEN + 1],tmpdir[MAXPATHLEN + 1];
|
||||
char newname[MAXPATHLEN + 1], dest_path[MAXPATHLEN + 1];
|
||||
Reference in New Issue
Block a user