🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.bug
Article #854

x11term.c bug in 18.59

#854
From: Israel Pinkas
Date: Thu, 12 Nov 1992 18:32
69 lines
2469 bytes
Emacs version
    18.59 (may be in earlier versions)

Environment
    USL SVR4.2/i386

config.h
    s-usg5-4.h
    m-intel386.h
    HAVE_X_WINDOWS

Other mods
    SVR4 needs CPP=/lib/cpp in src/Makefile

Bug description
    1. Emacs calls free() with a pointer that was returned by
    XrmGetResource().  Since Emacs did not allocate this memory, it should
    not assume that it is free()able.

    2. XrmGetResource() returns a pointer to a static area that is later
    overwritten.  Emacs should copy the data returned by XrmGetResource()
    to a buffer that it allocates with malloc().

Repeat with
    Place a resource in .Xdefaults that can be changed from inside Emacs
    (e.g. *foreground: #000000000000).  Change the resource inside Emacs
    (e.g. M-x x-set-foreground-color red).  Emacs will die calling free().

Fix
    Emacs should make a copy of the data returned by XrmGetResource().
    Context diff follows.

Comments
    Someone should determine whether the XGetDefault() calls could ever
    suffer from the same problem.


-Israel Pinkas

----------------------------------------------------------------------

*** e59/src/x11term.c.orig	Wed Nov 11 18:30:06 1992
--- e59/src/x11term.c	Wed Nov 11 18:36:42 1992
***************
*** 1631,1638 ****
  
        if (XrmGetResource (db, iname, cname, &dummy, &value))
  	{
! 	  if (entry->varp)
! 	    *entry->varp = (char*)value.addr;
  	}
        else
  	{
--- 1631,1640 ----
  
        if (XrmGetResource (db, iname, cname, &dummy, &value))
  	{
! 	  if (entry->varp) {
! 	    *entry->varp = (char *)xmalloc((size_t)value.size);
! 	    bcopy((char*)value.addr, *entry->varp, (size_t)value.size);
! 	  }
  	}
        else
  	{
--
Israel Pinkas		pinkas@stps18.intel.com		408-765-4210

	"Everybody's askaird of death, until it hits you ...
	 then you don't care"		-Archie Bunker
Technical Details
Message-ID: <PINKAS.92Nov12103215@skywalker.intel.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!convex!darwin.sura.net!europa.asd.contel.com!emory!swrinde!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!cis.ohio-state.edu!skywalker.intel.com!pinkas

Show Full Headers
Complete Article Headers
Newsgroups: gnu.emacs.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!convex!darwin.sura.net!europa.asd.contel.com!emory!swrinde!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!cis.ohio-state.edu!skywalker.intel.com!pinkas
From: pinkas@skywalker.intel.com (Israel Pinkas)
Subject: x11term.c bug in 18.59
Message-ID: <PINKAS.92Nov12103215@skywalker.intel.com>
Sender: gnulists@ai.mit.edu
Organization: Software Technologies, INTeL Corporation, Santa Clara, CA
Distribution: gnu
Date: Thu, 12 Nov 1992 18:32:15 GMT
Approved: bug-gnu-emacs@prep.ai.mit.edu
Lines: 70