Browse Source

ndk-patches: avoid free()'ing pointer which is still in use

emacs-27
Leonid Plyushch 5 years ago
parent
commit
fc930a5a84
No known key found for this signature in database GPG Key ID: 45F2964132545795
  1. 11
      ndk-patches/stdio.h.patch

11
ndk-patches/stdio.h.patch

@ -1,6 +1,6 @@
diff -u -r /home/fornwall/lib/android-ndk/sysroot/usr/include/stdio.h ./usr/include/stdio.h diff -uNr ./usr.old/include/stdio.h ./usr/include/stdio.h
--- /home/fornwall/lib/android-ndk/sysroot/usr/include/stdio.h 2017-11-09 09:57:12.000000000 +0100 --- ./usr.old/include/stdio.h 2019-05-22 12:49:28.000000000 +0300
+++ ./usr/include/stdio.h 2017-11-15 11:57:58.567432093 +0100 +++ ./usr/include/stdio.h 2019-12-13 21:50:02.765565736 +0200
@@ -44,11 +44,12 @@ @@ -44,11 +44,12 @@
#include <stdarg.h> #include <stdarg.h>
#include <stddef.h> #include <stddef.h>
@ -53,7 +53,7 @@ diff -u -r /home/fornwall/lib/android-ndk/sysroot/usr/include/stdio.h ./usr/incl
FILE* fdopen(int __fd, const char* __mode); FILE* fdopen(int __fd, const char* __mode);
int fileno(FILE* __fp); int fileno(FILE* __fp);
@@ -328,6 +332,29 @@ @@ -328,6 +332,30 @@
#include <bits/fortify/stdio.h> #include <bits/fortify/stdio.h>
#endif #endif
@ -70,12 +70,13 @@ diff -u -r /home/fornwall/lib/android-ndk/sysroot/usr/include/stdio.h ./usr/incl
+ unsigned int r = arc4random(); + unsigned int r = arc4random();
+ if (asprintf(&path, "@TERMUX_PREFIX@/tmp/tmpfile.%d-%u", p, r) == -1) return NULL; + if (asprintf(&path, "@TERMUX_PREFIX@/tmp/tmpfile.%d-%u", p, r) == -1) return NULL;
+ int fd = open(path, O_RDWR | O_CREAT | O_EXCL | O_LARGEFILE, 0600); + int fd = open(path, O_RDWR | O_CREAT | O_EXCL | O_LARGEFILE, 0600);
+ free(path);
+ if (fd >= 0) { + if (fd >= 0) {
+ FILE* result = fdopen(fd, "w+"); + FILE* result = fdopen(fd, "w+");
+ unlink(path); + unlink(path);
+ free(path);
+ return result; + return result;
+ } + }
+ free(path);
+ } + }
+ return NULL; + return NULL;
+} +}

Loading…
Cancel
Save