Fix memory leak. (#74400, Morten Welinder.)
Fri Mar 22 10:56:19 2002 Owen Taylor <otaylor@redhat.com> * gtk/gtkaccelmap.c (gtk_accel_map_save_fd): Fix memory leak. (#74400, Morten Welinder.) * gtk/gtkaccelmap.c: Properly handle short returns from write() calls. (Handling EINTR isn't enough... that only handles the case where you were interrupted before you wrote a single byte.) * gdk/linux-fb/gdkmouse-fb.c gdk/linux-fb/gdkkeyboard-fb.c: Robustify against short returns from write() calls.
This commit is contained in:
13
ChangeLog
13
ChangeLog
@ -1,3 +1,16 @@
|
|||||||
|
Fri Mar 22 10:56:19 2002 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
* gtk/gtkaccelmap.c (gtk_accel_map_save_fd): Fix memory
|
||||||
|
leak. (#74400, Morten Welinder.)
|
||||||
|
|
||||||
|
* gtk/gtkaccelmap.c: Properly handle short returns from
|
||||||
|
write() calls. (Handling EINTR isn't enough... that only
|
||||||
|
handles the case where you were interrupted before you
|
||||||
|
wrote a single byte.)
|
||||||
|
|
||||||
|
* gdk/linux-fb/gdkmouse-fb.c gdk/linux-fb/gdkkeyboard-fb.c:
|
||||||
|
Robustify against short returns from write() calls.
|
||||||
|
|
||||||
Fri Mar 22 10:12:10 2002 Owen Taylor <otaylor@redhat.com>
|
Fri Mar 22 10:12:10 2002 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
* gtk/gtktextview.c (gtk_text_view_paint): Change
|
* gtk/gtktextview.c (gtk_text_view_paint): Change
|
||||||
|
@ -1,3 +1,16 @@
|
|||||||
|
Fri Mar 22 10:56:19 2002 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
* gtk/gtkaccelmap.c (gtk_accel_map_save_fd): Fix memory
|
||||||
|
leak. (#74400, Morten Welinder.)
|
||||||
|
|
||||||
|
* gtk/gtkaccelmap.c: Properly handle short returns from
|
||||||
|
write() calls. (Handling EINTR isn't enough... that only
|
||||||
|
handles the case where you were interrupted before you
|
||||||
|
wrote a single byte.)
|
||||||
|
|
||||||
|
* gdk/linux-fb/gdkmouse-fb.c gdk/linux-fb/gdkkeyboard-fb.c:
|
||||||
|
Robustify against short returns from write() calls.
|
||||||
|
|
||||||
Fri Mar 22 10:12:10 2002 Owen Taylor <otaylor@redhat.com>
|
Fri Mar 22 10:12:10 2002 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
* gtk/gtktextview.c (gtk_text_view_paint): Change
|
* gtk/gtktextview.c (gtk_text_view_paint): Change
|
||||||
|
@ -1,3 +1,16 @@
|
|||||||
|
Fri Mar 22 10:56:19 2002 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
* gtk/gtkaccelmap.c (gtk_accel_map_save_fd): Fix memory
|
||||||
|
leak. (#74400, Morten Welinder.)
|
||||||
|
|
||||||
|
* gtk/gtkaccelmap.c: Properly handle short returns from
|
||||||
|
write() calls. (Handling EINTR isn't enough... that only
|
||||||
|
handles the case where you were interrupted before you
|
||||||
|
wrote a single byte.)
|
||||||
|
|
||||||
|
* gdk/linux-fb/gdkmouse-fb.c gdk/linux-fb/gdkkeyboard-fb.c:
|
||||||
|
Robustify against short returns from write() calls.
|
||||||
|
|
||||||
Fri Mar 22 10:12:10 2002 Owen Taylor <otaylor@redhat.com>
|
Fri Mar 22 10:12:10 2002 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
* gtk/gtktextview.c (gtk_text_view_paint): Change
|
* gtk/gtktextview.c (gtk_text_view_paint): Change
|
||||||
|
@ -1,3 +1,16 @@
|
|||||||
|
Fri Mar 22 10:56:19 2002 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
* gtk/gtkaccelmap.c (gtk_accel_map_save_fd): Fix memory
|
||||||
|
leak. (#74400, Morten Welinder.)
|
||||||
|
|
||||||
|
* gtk/gtkaccelmap.c: Properly handle short returns from
|
||||||
|
write() calls. (Handling EINTR isn't enough... that only
|
||||||
|
handles the case where you were interrupted before you
|
||||||
|
wrote a single byte.)
|
||||||
|
|
||||||
|
* gdk/linux-fb/gdkmouse-fb.c gdk/linux-fb/gdkkeyboard-fb.c:
|
||||||
|
Robustify against short returns from write() calls.
|
||||||
|
|
||||||
Fri Mar 22 10:12:10 2002 Owen Taylor <otaylor@redhat.com>
|
Fri Mar 22 10:12:10 2002 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
* gtk/gtktextview.c (gtk_text_view_paint): Change
|
* gtk/gtktextview.c (gtk_text_view_paint): Change
|
||||||
|
@ -1,3 +1,16 @@
|
|||||||
|
Fri Mar 22 10:56:19 2002 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
* gtk/gtkaccelmap.c (gtk_accel_map_save_fd): Fix memory
|
||||||
|
leak. (#74400, Morten Welinder.)
|
||||||
|
|
||||||
|
* gtk/gtkaccelmap.c: Properly handle short returns from
|
||||||
|
write() calls. (Handling EINTR isn't enough... that only
|
||||||
|
handles the case where you were interrupted before you
|
||||||
|
wrote a single byte.)
|
||||||
|
|
||||||
|
* gdk/linux-fb/gdkmouse-fb.c gdk/linux-fb/gdkkeyboard-fb.c:
|
||||||
|
Robustify against short returns from write() calls.
|
||||||
|
|
||||||
Fri Mar 22 10:12:10 2002 Owen Taylor <otaylor@redhat.com>
|
Fri Mar 22 10:12:10 2002 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
* gtk/gtktextview.c (gtk_text_view_paint): Change
|
* gtk/gtktextview.c (gtk_text_view_paint): Change
|
||||||
|
@ -1,3 +1,16 @@
|
|||||||
|
Fri Mar 22 10:56:19 2002 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
* gtk/gtkaccelmap.c (gtk_accel_map_save_fd): Fix memory
|
||||||
|
leak. (#74400, Morten Welinder.)
|
||||||
|
|
||||||
|
* gtk/gtkaccelmap.c: Properly handle short returns from
|
||||||
|
write() calls. (Handling EINTR isn't enough... that only
|
||||||
|
handles the case where you were interrupted before you
|
||||||
|
wrote a single byte.)
|
||||||
|
|
||||||
|
* gdk/linux-fb/gdkmouse-fb.c gdk/linux-fb/gdkkeyboard-fb.c:
|
||||||
|
Robustify against short returns from write() calls.
|
||||||
|
|
||||||
Fri Mar 22 10:12:10 2002 Owen Taylor <otaylor@redhat.com>
|
Fri Mar 22 10:12:10 2002 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
* gtk/gtktextview.c (gtk_text_view_paint): Change
|
* gtk/gtktextview.c (gtk_text_view_paint): Change
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include <gdk/gdkinternals.h>
|
#include <gdk/gdkinternals.h>
|
||||||
#include "gdkkeysyms.h"
|
#include "gdkkeysyms.h"
|
||||||
#include "gdkprivate-fb.h"
|
#include "gdkprivate-fb.h"
|
||||||
|
#include <errno.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -871,6 +872,30 @@ xlate_io (GIOChannel *gioc,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
write_string (gint fd,
|
||||||
|
gchar *str)
|
||||||
|
{
|
||||||
|
gsize to_write = strlen (string);
|
||||||
|
|
||||||
|
while (to_write > 0)
|
||||||
|
{
|
||||||
|
gssize count = write (fd, str, to_write);
|
||||||
|
if (count < 0)
|
||||||
|
{
|
||||||
|
if (errno != EINTR)
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
to_write -= count;
|
||||||
|
str += count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
xlate_open (GdkFBKeyboard *kb)
|
xlate_open (GdkFBKeyboard *kb)
|
||||||
{
|
{
|
||||||
@ -886,7 +911,7 @@ xlate_open (GdkFBKeyboard *kb)
|
|||||||
|
|
||||||
tcsetpgrp (gdk_display->tty_fd, getpgrp());
|
tcsetpgrp (gdk_display->tty_fd, getpgrp());
|
||||||
|
|
||||||
write (gdk_display->tty_fd, cursoroff_str, strlen (cursoroff_str));
|
write_string (gdk_display->tty_fd, cursoroff_str);
|
||||||
|
|
||||||
ioctl (gdk_display->tty_fd, KDSKBMODE, K_XLATE);
|
ioctl (gdk_display->tty_fd, KDSKBMODE, K_XLATE);
|
||||||
|
|
||||||
@ -906,7 +931,7 @@ xlate_close (GdkFBKeyboard *kb)
|
|||||||
struct termios ts;
|
struct termios ts;
|
||||||
const char cursoron_str[] = "\033c";
|
const char cursoron_str[] = "\033c";
|
||||||
|
|
||||||
write (gdk_display->tty_fd, cursoron_str, strlen (cursoron_str));
|
write_string (gdk_display->tty_fd, cursoron_str);
|
||||||
|
|
||||||
tcgetattr (gdk_display->tty_fd, &ts);
|
tcgetattr (gdk_display->tty_fd, &ts);
|
||||||
ts.c_lflag |= (ICANON|ECHO|ISIG);
|
ts.c_lflag |= (ICANON|ECHO|ISIG);
|
||||||
@ -1396,7 +1421,7 @@ raw_open (GdkFBKeyboard *kb)
|
|||||||
|
|
||||||
tcsetpgrp (gdk_display->tty_fd, getpgrp());
|
tcsetpgrp (gdk_display->tty_fd, getpgrp());
|
||||||
|
|
||||||
write (gdk_display->tty_fd, cursoroff_str, strlen (cursoroff_str));
|
write_string (gdk_display->tty_fd, cursoroff_str);
|
||||||
|
|
||||||
if (ioctl (gdk_display->tty_fd, KDSKBMODE, K_MEDIUMRAW) < 0)
|
if (ioctl (gdk_display->tty_fd, KDSKBMODE, K_MEDIUMRAW) < 0)
|
||||||
{
|
{
|
||||||
@ -1420,7 +1445,7 @@ raw_close (GdkFBKeyboard *kb)
|
|||||||
struct termios ts;
|
struct termios ts;
|
||||||
const char cursoron_str[] = "\033c";
|
const char cursoron_str[] = "\033c";
|
||||||
|
|
||||||
write (gdk_display->tty_fd, cursoron_str, strlen (cursoron_str));
|
write_string (gdk_display->tty_fd, cursoron_str);
|
||||||
|
|
||||||
tcgetattr (gdk_display->tty_fd, &ts);
|
tcgetattr (gdk_display->tty_fd, &ts);
|
||||||
ts.c_lflag |= (ICANON|ECHO|ISIG);
|
ts.c_lflag |= (ICANON|ECHO|ISIG);
|
||||||
|
@ -414,6 +414,29 @@ gdk_fb_mouse_dev_open (char *devname, gint mode)
|
|||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
write_all (gint fd,
|
||||||
|
gchar *buf,
|
||||||
|
gsize to_write)
|
||||||
|
{
|
||||||
|
while (to_write > 0)
|
||||||
|
{
|
||||||
|
gssize count = write (fd, buf, to_write);
|
||||||
|
if (count < 0)
|
||||||
|
{
|
||||||
|
if (errno != EINTR)
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
to_write -= count;
|
||||||
|
buf += count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gdk_fb_mouse_ps2_open (GdkFBMouse *mouse)
|
gdk_fb_mouse_ps2_open (GdkFBMouse *mouse)
|
||||||
{
|
{
|
||||||
@ -433,7 +456,11 @@ gdk_fb_mouse_ps2_open (GdkFBMouse *mouse)
|
|||||||
buf[i++] = 232; /* device resolution */
|
buf[i++] = 232; /* device resolution */
|
||||||
buf[i++] = 1;
|
buf[i++] = 1;
|
||||||
|
|
||||||
write (fd, buf, i);
|
if (!write_all (fd, buf, i))
|
||||||
|
{
|
||||||
|
close (fd);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
usleep (10000); /* sleep 10 ms, then read whatever junk we can get from the mouse, in a vain attempt
|
usleep (10000); /* sleep 10 ms, then read whatever junk we can get from the mouse, in a vain attempt
|
||||||
to get synchronized with the event stream */
|
to get synchronized with the event stream */
|
||||||
@ -542,7 +569,11 @@ gdk_fb_mouse_ms_open (GdkFBMouse *mouse)
|
|||||||
tty.c_cc[VMIN] = 1;
|
tty.c_cc[VMIN] = 1;
|
||||||
tcsetattr (fd, TCSAFLUSH, &tty);
|
tcsetattr (fd, TCSAFLUSH, &tty);
|
||||||
|
|
||||||
write (fd, "*n", 2);
|
if (!write_all (fd, "*n", 2))
|
||||||
|
{
|
||||||
|
close (fd);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
mouse->fd = fd;
|
mouse->fd = fd;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include "gtkwindow.h" /* in lack of GtkAcceleratable */
|
#include "gtkwindow.h" /* in lack of GtkAcceleratable */
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#ifdef HAVE_UNISTD_H
|
#ifdef HAVE_UNISTD_H
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@ -586,6 +587,29 @@ gtk_accel_map_load (const gchar *file_name)
|
|||||||
close (fd);
|
close (fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
write_all (gint fd,
|
||||||
|
gchar *buf,
|
||||||
|
gsize to_write)
|
||||||
|
{
|
||||||
|
while (to_write > 0)
|
||||||
|
{
|
||||||
|
gssize count = write (fd, buf, to_write);
|
||||||
|
if (count < 0)
|
||||||
|
{
|
||||||
|
if (errno != EINTR)
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
to_write -= count;
|
||||||
|
buf += count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
accel_map_print (gpointer data,
|
accel_map_print (gpointer data,
|
||||||
const gchar *accel_path,
|
const gchar *accel_path,
|
||||||
@ -594,7 +618,7 @@ accel_map_print (gpointer data,
|
|||||||
gboolean changed)
|
gboolean changed)
|
||||||
{
|
{
|
||||||
GString *gstring = g_string_new (changed ? NULL : "; ");
|
GString *gstring = g_string_new (changed ? NULL : "; ");
|
||||||
gint err, fd = GPOINTER_TO_INT (data);
|
gint fd = GPOINTER_TO_INT (data);
|
||||||
gchar *tmp, *name;
|
gchar *tmp, *name;
|
||||||
|
|
||||||
g_string_append (gstring, "(gtk_accel_path \"");
|
g_string_append (gstring, "(gtk_accel_path \"");
|
||||||
@ -613,9 +637,7 @@ accel_map_print (gpointer data,
|
|||||||
|
|
||||||
g_string_append (gstring, "\")\n");
|
g_string_append (gstring, "\")\n");
|
||||||
|
|
||||||
do
|
write_all (fd, gstring->str, gstring->len);
|
||||||
err = write (fd, gstring->str, gstring->len);
|
|
||||||
while (err < 0 && errno == EINTR);
|
|
||||||
|
|
||||||
g_string_free (gstring, TRUE);
|
g_string_free (gstring, TRUE);
|
||||||
}
|
}
|
||||||
@ -632,7 +654,6 @@ void
|
|||||||
gtk_accel_map_save_fd (gint fd)
|
gtk_accel_map_save_fd (gint fd)
|
||||||
{
|
{
|
||||||
GString *gstring;
|
GString *gstring;
|
||||||
gint err;
|
|
||||||
|
|
||||||
g_return_if_fail (fd >= 0);
|
g_return_if_fail (fd >= 0);
|
||||||
|
|
||||||
@ -643,9 +664,9 @@ gtk_accel_map_save_fd (gint fd)
|
|||||||
g_string_append (gstring, "; this file is an automated accelerator map dump\n");
|
g_string_append (gstring, "; this file is an automated accelerator map dump\n");
|
||||||
g_string_append (gstring, ";\n");
|
g_string_append (gstring, ";\n");
|
||||||
|
|
||||||
do
|
write_all (fd, gstring->str, gstring->len);
|
||||||
err = write (fd, gstring->str, gstring->len);
|
|
||||||
while (err < 0 && errno == EINTR);
|
g_string_free (gstring, TRUE);
|
||||||
|
|
||||||
gtk_accel_map_foreach (GINT_TO_POINTER (fd), accel_map_print);
|
gtk_accel_map_foreach (GINT_TO_POINTER (fd), accel_map_print);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user