summaryrefslogtreecommitdiff
path: root/x11/mlterm/patches/patch-al
diff options
context:
space:
mode:
Diffstat (limited to 'x11/mlterm/patches/patch-al')
-rw-r--r--x11/mlterm/patches/patch-al52
1 files changed, 52 insertions, 0 deletions
diff --git a/x11/mlterm/patches/patch-al b/x11/mlterm/patches/patch-al
new file mode 100644
index 00000000000..b583120a618
--- /dev/null
+++ b/x11/mlterm/patches/patch-al
@@ -0,0 +1,52 @@
+$NetBSD: patch-al,v 1.1 2006/12/19 07:53:57 wiz Exp $
+
+plugged fd leaks.
+
+http://mlterm.cvs.sourceforge.net/mlterm/mlterm/xwindow/x_xim.c?r1=1.9&r2=1.11&view=patch
+
+--- xwindow/x_xim.c.orig 2005/02/10 15:15:08 1.9
++++ xwindow/x_xim.c 2006/10/23 13:09:36 1.11
+@@ -5,6 +5,8 @@
+
+ #include "x_xim.h"
+
+ #include <stdio.h> /* sprintf */
+ #include <string.h> /* strcmp/memset */
++#include <unistd.h> /* dup/close */
++#include <kiklib/kik_file.h> /* kik_set_file_cloexec */
+ #include <kiklib/kik_debug.h>
+@@ -121,6 +123,7 @@
+ char * xmod ;
+ char * cur_locale ;
+ int result ;
++ int next_fd ; /* to deal with brain-dead XIM implemantations */
+
+ /* 4 is the length of "@im=" */
+ if( ( xmod = alloca( 4 + strlen( xim->name) + 1)) == NULL)
+@@ -154,6 +157,12 @@
+
+ result = 0 ;
+
++ next_fd = dup( 0) ;
++ if( next_fd != -1)
++ {
++ /* remember the lowest unused fd */
++ close( next_fd) ;
++ }
+ if( XSetLocaleModifiers(xmod) && ( xim->im = XOpenIM( display , NULL , NULL , NULL)))
+ {
+ if( ( xim->encoding = ml_get_char_encoding( kik_get_codeset())) == ML_UNKNOWN_ENCODING ||
+@@ -172,7 +181,12 @@
+ result = 1 ;
+ }
+ }
+-
++ if( next_fd > 0)
++ {
++ /* if XOpenIM() internally opens a fd,
++ * we should close it on exec() */
++ kik_file_set_cloexec( next_fd) ;
++ }
+ if( cur_locale)
+ {
+ /* restoring */