Thu Nov 16 16:40:54 PST 2000 Michael Jennings <mej@eterm.org>

VA bought some licenses for Insure++, so I've been using it to audit
	Eterm.  These are just the initial results of the collaboration; there
	will most likely be more.  So far things are looking pretty good.  I
	just wish Insure++ had more helpful messages.  I'd really love to be
	able to track down those reads/writes involving freed pointers that
	it claims to have found in Imlib2....

	I also had to try and make the build work without MMX.  I did so; I
	just hope it still works *with* MMX.... =)


SVN revision: 3895
This commit is contained in:
Michael Jennings 2000-11-16 23:45:01 +00:00
parent 1bcfa73217
commit 2b30d160f4
16 changed files with 202 additions and 54 deletions

View File

@ -3977,3 +3977,16 @@ Wed Nov 15 14:20:13 PST 2000 Michael Jennings <mej@eterm.org>
key will activate Eterm's "steal focus" mechanism.
-------------------------------------------------------------------------------
Thu Nov 16 16:40:54 PST 2000 Michael Jennings <mej@eterm.org>
VA bought some licenses for Insure++, so I've been using it to audit
Eterm. These are just the initial results of the collaboration; there
will most likely be more. So far things are looking pretty good. I
just wish Insure++ had more helpful messages. I'd really love to be
able to track down those reads/writes involving freed pointers that
it claims to have found in Imlib2....
I also had to try and make the build work without MMX. I did so; I
just hope it still works *with* MMX.... =)
-------------------------------------------------------------------------------

View File

@ -363,18 +363,19 @@ AC_ARG_ENABLE(trans,
AC_MSG_CHECKING(for MMX support)
HAVE_MMX=""
AC_ARG_ENABLE(mmx, [ --enable-mmx enable MMX assembly routines],
test x$enableval = xyes && HAVE_MMX="yes"
test "x$enableval" = "xyes" && HAVE_MMX="yes"
,
if test x$build_os = xlinux-gnu; then
grep mmx /proc/cpuinfo >/dev/null 2>&1 && HAVE_MMX="yes"
fi
)
if test -n "$HAVE_MMX"; then
if test "x$HAVE_MMX" = "xyes"; then
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_MMX)
else
AC_MSG_RESULT(no)
fi
AM_CONDITIONAL(HAVE_MMX, test "x$HAVE_MMX" = "xyes")
dnl#
dnl# LibAST

View File

@ -3,6 +3,9 @@
lib_LTLIBRARIES = libEterm.la
bin_PROGRAMS = Eterm
MMX_SRCS = mmx_cmod.S
MMX_OBJS = $(MMX_SRCS:.S.o)
libEterm_la_SOURCES = actions.c actions.h buttons.c buttons.h command.c \
command.h draw.c draw.h e.c e.h eterm_debug.h eterm_utmp.h \
events.c events.h feature.h font.c font.h grkelot.c \
@ -10,14 +13,22 @@ libEterm_la_SOURCES = actions.c actions.h buttons.c buttons.h command.c
options.c options.h pixmap.c pixmap.h profile.h screen.c \
screen.h scrollbar.c scrollbar.h startup.c startup.h \
system.c system.h term.c term.h timer.c timer.h utmp.c \
windows.c windows.h mmx_cmod.S
libEterm_la_DEPENDENCIES = feature.h
windows.c windows.h
libEterm_la_DEPENDENCIES = feature.h $(MMX_OBJS)
libEterm_la_LDFLAGS = -release $(VERSION)
libEterm_la_LDADD = $(MMX_OBJS)
Eterm_SOURCES = main.c
Eterm_DEPENDENCIES = libEterm.la
Eterm_LDFLAGS = -rpath $(libdir):$(pkglibdir)
Eterm_LDADD = libEterm.la
Eterm_LDADD = libEterm.la
if HAVE_MMX
$(MMX_OBJS): $(MMX_SRCS)
else
$(MMX_OBJS):
touch $(MMX_OBJS)
endif
install-exec-hook:
$(mkinstalldirs) $(DESTDIR)$(pkgdatadir)

View File

@ -108,6 +108,33 @@ bbar_create(void)
return bbar;
}
void
bbar_free(buttonbar_t *bbar)
{
button_t *b;
if (bbar->next) {
bbar_free(bbar->next);
}
button_free(bbar->rbuttons);
button_free(bbar->buttons);
#ifdef MULTI_CHARSET
if (bbar->fontset) {
XFreeFontSet(Xdisplay, bbar->fontset);
}
#endif
if (bbar->font) {
free_font(bbar->font);
}
if (bbar->gc != None) {
LIBAST_X_FREE_GC(bbar->gc);
}
if (bbar->win != None) {
XDestroyWindow(Xdisplay, bbar->win);
}
FREE(bbar);
}
void
bbar_init(buttonbar_t *bbar, int width)
{
@ -579,12 +606,30 @@ button_create(char *text)
button->text = STRDUP(text);
button->len = strlen(text);
} else {
button->text = "";
button->text = STRDUP("");
button->len = 0;
}
return button;
}
void
button_free(button_t *button)
{
if (button->next) {
button_free(button->next);
}
if (button->text) {
FREE(button->text);
}
if (button->type == ACTION_STRING || button->type == ACTION_ECHO) {
FREE(button->action.string);
}
if (button->icon) {
free_simage(button->icon);
}
FREE(button);
}
unsigned char
button_set_icon(button_t *button, simage_t *icon)
{

View File

@ -96,6 +96,7 @@ extern long bbar_total_h;
_XFUNCPROTOBEGIN
extern buttonbar_t *bbar_create(void);
extern void bbar_free(buttonbar_t *);
extern void bbar_init(buttonbar_t *, int);
extern void bbar_event_init_dispatcher(void);
extern unsigned char bbar_handle_enter_notify(event_t *);
@ -116,6 +117,7 @@ extern unsigned char bbar_set_font(buttonbar_t *bbar, const char *fontname);
extern button_t *find_button_by_text(buttonbar_t *bbar, char *text);
extern button_t *find_button_by_coords(buttonbar_t *bbar, int x, int y);
extern button_t *button_create(char *text);
extern void button_free(button_t *);
extern unsigned char button_set_icon(button_t *button, simage_t *icon);
extern unsigned char button_set_action(button_t *button, action_type_t type, char *action);
extern void bbar_select_button(buttonbar_t *bbar, button_t *button);

View File

@ -158,6 +158,7 @@ static char *v_bufend; /* end of physical buffer */
static Atom DndProtocol, DndSelection;
#endif /* OFFIX_DND */
#ifdef USE_XIM
XIM xim_input_method = NULL;
XIC xim_input_context = NULL; /* input context */
static XIMStyle xim_input_style = 0;
# ifndef XSetIMValues
@ -1121,13 +1122,30 @@ clean_exit(void)
{
#if DEBUG >= DEBUG_MEM
if (DEBUG_LEVEL >= DEBUG_MEM) {
unsigned short i;
/* Deallocate all our crap to help find memory leaks */
selection_clear();
scr_release();
bbar_free(buttonbar);
menulist_clear(menu_list);
font_cache_clear();
eterm_font_list_clear();
FOREACH_IMAGE(free_eterm_image(&(images[idx])););
for (i = 0; i < NRS_COLORS; i++) {
if (rs_color[i]) {
FREE(rs_color[i]);
}
}
conf_free_subsystem();
}
#endif
#ifdef USE_XIM
if (xim_input_method) {
XCloseIM(xim_input_method);
}
#endif
XCloseDisplay(Xdisplay);
privileges(INVOKE);
@ -1744,11 +1762,6 @@ init_locale(void)
if (locale == NULL) {
print_error("Setting locale failed.\n");
} else {
#ifdef MULTI_CHARSET
TermWin.fontset = create_fontset(etfonts[def_font_idx], etmfonts[def_font_idx]);
#else
TermWin.fontset = create_fontset(etfonts[def_font_idx], "-misc-fixed-medium-r-semicondensed--13-*-75-*-c-*-iso10646-1");
#endif
#ifdef USE_XIM
# ifdef MULTI_CHARSET
if (strcmp(locale, "C"))
@ -1763,6 +1776,13 @@ init_locale(void)
# endif
}
#endif
#ifdef MULTI_CHARSET
TermWin.fontset = create_fontset(etfonts[def_font_idx], etmfonts[def_font_idx]);
#else
TermWin.fontset = create_fontset(etfonts[def_font_idx], "-misc-fixed-medium-r-semicondensed--13-*-75-*-c-*-iso10646-1");
#endif
/* Reset locale to NULL since the call to create_fontset() has freed that memory. */
locale = NULL;
}
}
#endif /* USE_XIM || MULTI_CHARSET */
@ -1829,6 +1849,7 @@ static void
xim_destroy_cb(XIM xim, XPointer client_data, XPointer call_data)
{
xim_input_context = NULL;
xim_input_method = NULL;
XRegisterIMInstantiateCallback(Xdisplay, NULL, NULL, NULL, xim_instantiate_cb, NULL);
xim = NULL;
client_data = call_data = (XPointer) 0;
@ -1851,7 +1872,6 @@ xim_real_init(void)
{
char *p, *s, buf[64], tmp[1024];
char *end, *next_s;
XIM xim = NULL;
XIMStyles *xim_styles = NULL;
int found;
XPoint spot;
@ -1876,7 +1896,7 @@ xim_real_init(void)
*(end + 1) = '\0';
if (*s) {
snprintf(buf, sizeof(buf), "@im=%s", s);
if (((p = XSetLocaleModifiers(buf)) != NULL) && (*p) && ((xim = XOpenIM(Xdisplay, NULL, NULL, NULL)) != NULL)) {
if (((p = XSetLocaleModifiers(buf)) != NULL) && (*p) && ((xim_input_method = XOpenIM(Xdisplay, NULL, NULL, NULL)) != NULL)) {
break;
}
}
@ -1887,20 +1907,20 @@ xim_real_init(void)
}
/* try with XMODIFIERS env. var. */
if (xim == NULL && getenv("XMODIFIERS") && (p = XSetLocaleModifiers("")) != NULL && *p) {
xim = XOpenIM(Xdisplay, NULL, NULL, NULL);
if (xim_input_method == NULL && getenv("XMODIFIERS") && (p = XSetLocaleModifiers("")) != NULL && *p) {
xim_input_method = XOpenIM(Xdisplay, NULL, NULL, NULL);
}
/* try with no modifiers base */
if (xim == NULL && (p = XSetLocaleModifiers("@im=none")) != NULL && *p) {
xim = XOpenIM(Xdisplay, NULL, NULL, NULL);
if (xim_input_method == NULL && (p = XSetLocaleModifiers("@im=none")) != NULL && *p) {
xim_input_method = XOpenIM(Xdisplay, NULL, NULL, NULL);
}
if (xim == NULL) {
xim = XOpenIM(Xdisplay, NULL, NULL, NULL);
if (xim_input_method == NULL) {
xim_input_method = XOpenIM(Xdisplay, NULL, NULL, NULL);
}
if (xim == NULL) {
if (xim_input_method == NULL) {
return -1;
}
@ -1910,15 +1930,15 @@ xim_real_init(void)
destroy_cb.callback = xim_destroy_cb;
destroy_cb.client_data = NULL;
if (XSetIMValues(xim, XNDestroyCallback, &destroy_cb, NULL)) {
if (XSetIMValues(xim_input_method, XNDestroyCallback, &destroy_cb, NULL)) {
print_error("Could not set destroy callback to IM\n");
}
}
#endif
if ((XGetIMValues(xim, XNQueryInputStyle, &xim_styles, NULL)) || (!xim_styles)) {
if ((XGetIMValues(xim_input_method, XNQueryInputStyle, &xim_styles, NULL)) || (!xim_styles)) {
print_error("input method doesn't support any style\n");
XCloseIM(xim);
XCloseIM(xim_input_method);
return -1;
}
strncpy(tmp, (rs_preedit_type ? rs_preedit_type : "OverTheSpot,OffTheSpot,Root"), sizeof(tmp) - 1);
@ -1952,14 +1972,14 @@ xim_real_init(void)
if (found == 0) {
print_error("input method doesn't support my preedit type\n");
XCloseIM(xim);
XCloseIM(xim_input_method);
return -1;
}
if ((xim_input_style != (XIMPreeditNothing | XIMStatusNothing))
&& (xim_input_style != (XIMPreeditArea | XIMStatusArea))
&& (xim_input_style != (XIMPreeditPosition | XIMStatusNothing))) {
print_error("This program does not support the preedit type\n");
XCloseIM(xim);
XCloseIM(xim_input_method);
return -1;
}
if (xim_input_style & XIMPreeditPosition) {
@ -1975,7 +1995,7 @@ xim_real_init(void)
preedit_attr = XVaCreateNestedList(0, XNArea, &rect, XNForeground, fg, XNBackground, bg, XNFontSet, TermWin.fontset, NULL);
status_attr = XVaCreateNestedList(0, XNArea, &status_rect, XNForeground, fg, XNBackground, bg, XNFontSet, TermWin.fontset, NULL);
}
xim_input_context = XCreateIC(xim, XNInputStyle, xim_input_style, XNClientWindow, TermWin.parent, XNFocusWindow, TermWin.parent,
xim_input_context = XCreateIC(xim_input_method, XNInputStyle, xim_input_style, XNClientWindow, TermWin.parent, XNFocusWindow, TermWin.parent,
preedit_attr ? XNPreeditAttributes : NULL, preedit_attr, status_attr ? XNStatusAttributes : NULL, status_attr, NULL);
if (preedit_attr) {
XFree(preedit_attr);
@ -1985,7 +2005,7 @@ xim_real_init(void)
}
if (xim_input_context == NULL) {
print_error("Failed to create input context\n");
XCloseIM(xim);
XCloseIM(xim_input_method);
return -1;
}
if (xim_input_style & XIMPreeditArea)
@ -2055,7 +2075,7 @@ void xim_set_fontset(void)
* the slave.
*/
int
run_command(char *argv[])
run_command(char **argv)
{
ttymode_t tio;
@ -2226,7 +2246,7 @@ run_command(char *argv[])
/* init_command() */
void
init_command(char *argv[])
init_command(char **argv)
{
/* Initialize the command connection. This should be called after

View File

@ -476,6 +476,7 @@ menu_delete(menu_t *menu)
ASSERT(menu != NULL);
D_MENU(("Deleting menu \"%s\"\n", menu->title));
for (i = 0; i < menu->numitems; i++) {
menuitem_delete(menu->items[i]);
}
@ -497,12 +498,12 @@ menu_delete(menu_t *menu)
if (menu->font) {
free_font(menu->font);
}
if (menu->win) {
XDestroyWindow(Xdisplay, menu->win);
}
if (menu->swin) {
XDestroyWindow(Xdisplay, menu->swin);
}
if (menu->win) {
XDestroyWindow(Xdisplay, menu->win);
}
FREE(menu);
}

View File

@ -1164,7 +1164,7 @@ conf_init_subsystem(void) {
ctx_idx = 0;
context = (ctx_t *) MALLOC(sizeof(ctx_t) * ctx_cnt);
MEMSET(context, 0, sizeof(ctx_t) * ctx_cnt);
context[0].name = "null";
context[0].name = STRDUP("null");
context[0].handler = parse_null;
/* Initialize the context state stack and set the current context to "null" */
@ -1267,6 +1267,29 @@ conf_register_context_state(unsigned char ctx_id) {
return (ctx_state_idx);
}
void
conf_free_subsystem(void)
{
conf_var_t *v, *tmp;
unsigned long i;
for (v = conf_vars; v;) {
tmp = v;
v = v->next;
conf_free_var(tmp);
}
for (i = 0; i < builtin_idx; i++) {
FREE(builtins[i].name);
}
for (i = 0; i <= ctx_idx; i++) {
FREE(context[i].name);
}
FREE(ctx_state);
FREE(builtins);
FREE(fstate);
FREE(context);
}
static conf_var_t *
conf_new_var(void)
{

View File

@ -259,6 +259,7 @@ extern unsigned char conf_register_context(char *name, ctx_handler_t handler);
extern unsigned char conf_register_fstate(FILE *fp, char *path, char *outfile, unsigned long line, unsigned char flags);
extern unsigned char conf_register_builtin(char *name, eterm_func_ptr_t ptr);
extern unsigned char conf_register_context_state(unsigned char ctx_id);
extern void conf_free_subsystem(void);
extern char *chomp(char *);
extern char *shell_expand(char *);
extern char *conf_find_file(const char *file, const char *dir, const char *pathlist);

View File

@ -327,7 +327,12 @@ free_eterm_image(image_t *img)
if (img->disabled) {
free_simage(img->disabled);
}
#if 0
/* FIXME: There should really be an option to specify whether or not
to free the image itself, but since we never MALLOC() an entire
image_t, it's not really needed at this point. And I'm lazy. :-) */
FREE(img);
#endif
}
simage_t *
@ -366,19 +371,40 @@ reset_simage(simage_t *simg, unsigned long mask)
FREE(simg->iml->border);
simg->iml->border = NULL;
}
if ((mask & RESET_IMLIB_BEVEL) && simg->iml->bevel) {
FREE(simg->iml->bevel->edges);
FREE(simg->iml->bevel);
simg->iml->bevel = NULL;
}
if ((mask & RESET_IMLIB_PAD) && simg->iml->pad) {
FREE(simg->iml->pad);
simg->iml->pad = NULL;
}
if ((mask & RESET_IMLIB_MOD) && simg->iml->mod) {
FREE(simg->iml->mod);
simg->iml->mod = NULL;
}
if ((mask & RESET_IMLIB_RMOD) && simg->iml->rmod) {
if (simg->iml->rmod->imlib_mod) {
imlib_context_set_color_modifier(simg->iml->rmod->imlib_mod);
imlib_free_color_modifier();
}
FREE(simg->iml->rmod);
simg->iml->rmod = NULL;
}
if ((mask & RESET_IMLIB_GMOD) && simg->iml->gmod) {
if (simg->iml->gmod->imlib_mod) {
imlib_context_set_color_modifier(simg->iml->gmod->imlib_mod);
imlib_free_color_modifier();
}
FREE(simg->iml->gmod);
simg->iml->gmod = NULL;
}
if ((mask & RESET_IMLIB_BMOD) && simg->iml->bmod) {
if (simg->iml->bmod->imlib_mod) {
imlib_context_set_color_modifier(simg->iml->bmod->imlib_mod);
imlib_free_color_modifier();
}
FREE(simg->iml->bmod);
simg->iml->bmod = NULL;
}
@ -395,6 +421,8 @@ void
free_simage(simage_t *s)
{
reset_simage(s, RESET_ALL_SIMG);
FREE(s->iml);
FREE(s->pmap);
FREE(s);
}

View File

@ -143,18 +143,20 @@ enum {
#define RESET_ALL_TINT (RESET_IMLIB_RMOD | RESET_IMLIB_GMOD | RESET_IMLIB_BMOD)
#define RESET_ALL_MOD (RESET_IMLIB_MOD | RESET_IMLIB_RMOD | RESET_IMLIB_GMOD | RESET_IMLIB_BMOD)
#define RESET_IMLIB_BORDER (1UL << 4)
#define RESET_IMLIB_IM (1UL << 5)
#define RESET_ALL_IMLIB (RESET_ALL_MOD | RESET_IMLIB_BORDER | RESET_IMLIB_IM)
#define RESET_PMAP_GEOM (1UL << 6)
#define RESET_PMAP_PIXMAP (1UL << 7)
#define RESET_PMAP_MASK (1UL << 8)
#define RESET_IMLIB_BEVEL (1UL << 5)
#define RESET_IMLIB_PAD (1UL << 6)
#define RESET_IMLIB_IM (1UL << 7)
#define RESET_ALL_IMLIB (RESET_ALL_MOD | RESET_IMLIB_BORDER | RESET_IMLIB_BEVEL | RESET_IMLIB_PAD | RESET_IMLIB_IM)
#define RESET_PMAP_GEOM (1UL << 8)
#define RESET_PMAP_PIXMAP (1UL << 9)
#define RESET_PMAP_MASK (1UL << 10)
#define RESET_ALL_PMAP (RESET_PMAP_GEOM | RESET_PMAP_PIXMAP | RESET_PMAP_MASK)
#define RESET_ALL_SIMG (RESET_ALL_IMLIB | RESET_ALL_PMAP)
#define RESET_NORM (1UL << 9)
#define RESET_SELECTED (1UL << 10)
#define RESET_CLICKED (1UL << 11)
#define RESET_DISABLED (1UL << 12)
#define RESET_MODE (1UL << 13)
#define RESET_NORM (1UL << 11)
#define RESET_SELECTED (1UL << 12)
#define RESET_CLICKED (1UL << 13)
#define RESET_DISABLED (1UL << 14)
#define RESET_MODE (1UL << 15)
#define RESET_ALL (RESET_NORM | RESET_SELECTED | RESET_CLICKED | RESET_DISABLED | RESET_MODE)
/************ Structures ************/

View File

@ -302,7 +302,7 @@ scr_reset(void)
if (tabs)
FREE(tabs);
}
tabs = MALLOC(TermWin.ncol * sizeof(char));
tabs = MALLOC(TermWin.ncol);
for (i = 0; i < TermWin.ncol; i++)
tabs[i] = (i % TABSIZE == 0) ? 1 : 0;
@ -2163,7 +2163,7 @@ scr_search_scrollback(char *str)
for (row = 0; row < rows; row++) {
if (screen.text[row]) {
c = screen.text[row];
for (s = strstr(c, str); s; s = strstr(++s, str)) {
for (s = strstr(c, str); s; s = strstr(s + 1, str)) {
unsigned long j;
col = (int) s - (int) c;
@ -3089,13 +3089,13 @@ selection_extend_colrow(int col, int row, int flag, int cont)
}
}
#ifdef MULTI_CHARSET
if (selection.beg.col > 0) {
if ((selection.beg.col > 0) && (selection.beg.col < TermWin.ncol)) {
r = selection.beg.row + TermWin.saveLines;
if (((screen.rend[r][selection.beg.col] & RS_multiMask) == RS_multi2)
&& ((screen.rend[r][selection.beg.col - 1] & RS_multiMask) == RS_multi1))
selection.beg.col--;
}
if (selection.end.col < TermWin.ncol - 1) {
if ((selection.end.col > 0) && (selection.end.col < (TermWin.ncol - 1))) {
r = selection.end.row + TermWin.saveLines;
if (((screen.rend[r][selection.end.col] & RS_multiMask) == RS_multi1)
&& ((screen.rend[r][selection.end.col + 1] & RS_multiMask) == RS_multi2))

View File

@ -64,7 +64,7 @@ short bg_needs_update = 1;
TermWin_t TermWin;
Display *Xdisplay; /* display */
Colormap cmap;
const char *display_name = NULL;
char *display_name = NULL;
unsigned int colorfgbg;
int
@ -92,8 +92,11 @@ eterm_bootstrap(int argc, char *argv[])
libast_set_program_version(VERSION);
/* Open display, get options/resources and create the window */
if ((display_name = getenv("DISPLAY")) == NULL)
display_name = ":0";
if (getenv("DISPLAY") == NULL) {
display_name = STRDUP(":0");
} else {
display_name = STRDUP(getenv("DISPLAY"));
}
/* This MUST be called before any other Xlib functions */

View File

@ -134,7 +134,7 @@ extern char *orig_argv0;
#ifdef PIXMAP_SUPPORT
extern short bg_needs_update;
#endif
extern const char *display_name;
extern char *display_name;
/************ Function Prototypes ************/
_XFUNCPROTOBEGIN

View File

@ -98,6 +98,7 @@ system_wait(char *command)
D_OPTIONS(("%d: fork() returned %d\n", getpid(), pid));
return (wait_for_chld(pid));
}
ASSERT_NOTREACHED_RVAL(0);
}
int

View File

@ -142,16 +142,13 @@ void
add_utmp_entry(const char *pty, const char *hostname, int fd)
{
struct passwd *pwent = getpwuid(my_ruid);
# ifdef HAVE_UTMPX_H
struct utmpx utmp;
struct utmp utmp2;
MEMSET(&utmp, 0, sizeof(struct utmpx));
# else
struct utmp utmp;
MEMSET(&utmp, 0, sizeof(struct utmp));
# endif
# ifdef WITH_DMALLOC