[Thread Prev][Thread Next]   >Date Index >Thread Index

[wmx] Patch: GC (& Pixmap) double-free crash

Andrew Chadwick - Thu Jan 14 14:34:16 1999

Hi!

A fix for Border.C. Border::~Border() would free the static m_drawGC and
m_backgroundPixmap correctly when no borders remain on-screen, but the
constructor wouldn't rebuild them when more borders were called for. The
constructor inits test m_tabFont alone, so:

>>>CUT HERE>>>>>>>>>>>>>>>>>>>>>>>>>>
*** wmx-5/Border.C	Wed Jan 13 10:28:43 1999
--- piffle_wmx5/Border.C	Thu Jan 14 00:42:00 1999
***************
*** 95,101 ****
--- 95,104 ----
  
      if (m_label) free(m_label);
  
+     // Zap statics (TODO: this wise here?)
      if (--borderCounter == 0) {
+         XRotUnloadFont(display(), m_tabFont);
+ 	m_tabFont = 0; //zeroing neccessary
  	XFreeGC(display(), m_drawGC);
  	if (m_backgroundPixmap != None) {
  	    XFreePixmap(display(), m_backgroundPixmap);
<<<<<<<<<<<<<<<<<<<<<<<CUT HERE<<<<<

A question: the static Border structures are freed when they're not needed -
is this just good X practice, or is it exit cleanup code?


	regards,
	Andrew



Next: