Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[xsrc/trunk]: xsrc/external/mit/libXau/dist Don't use atexit(3) to free the b...



details:   https://anonhg.NetBSD.org/xsrc/rev/200cdfec3a2e
branches:  trunk
changeset: 10077:200cdfec3a2e
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Jan 04 18:53:36 2019 +0000

description:
Don't use atexit(3) to free the buffer. Use a destructor instead so we don't
segv if someone dlopened and dlclosed the library. Should fix:
    http://mail-index.netbsd.org/tech-userlevel/2018/12/27/msg011624.html

diffstat:

 external/mit/libXau/dist/AuFileName.c |  7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diffs (36 lines):

diff -r 385d698a1204 -r 200cdfec3a2e external/mit/libXau/dist/AuFileName.c
--- a/external/mit/libXau/dist/AuFileName.c     Fri Jan 04 00:09:24 2019 +0000
+++ b/external/mit/libXau/dist/AuFileName.c     Fri Jan 04 18:53:36 2019 +0000
@@ -34,6 +34,9 @@
 static char *buf = NULL;
 
 static void
+#ifdef __NetBSD__
+__attribute__ ((__destructor__))
+#endif
 free_filename_buffer(void)
 {
     free(buf);
@@ -46,7 +49,9 @@
     const char *slashDotXauthority = "/.Xauthority";
     char    *name;
     static size_t      bsize;
+#ifndef __NetBSD__
     static int atexit_registered = 0;
+#endif
 #ifdef WIN32
     char    dir[128];
 #endif
@@ -73,10 +78,12 @@
        if (!buf)
            return NULL;
 
+#ifndef __NetBSD__
         if (!atexit_registered) {
             atexit(free_filename_buffer);
             atexit_registered = 1;
         }
+#endif
 
        bsize = size;
     }



Home | Main Index | Thread Index | Old Index