[Python-checkins] python/dist/src/Modules socketmodule.c,1.216,1.217

gvanrossum@users.sourceforge.net gvanrossum@users.sourceforge.net
Thu, 06 Jun 2002 13:08:29 -0700


Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv1284

Modified Files:
	socketmodule.c 
Log Message:
The tp_new implementation should initialize the errorhandler field,
otherwise this code could segfault:

  from socket import socket
  s = socket.__new__(socket)
  s.recv(100)


Index: socketmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.c,v
retrieving revision 1.216
retrieving revision 1.217
diff -C2 -d -r1.216 -r1.217
*** socketmodule.c	27 Apr 2002 18:44:31 -0000	1.216
--- socketmodule.c	6 Jun 2002 20:08:25 -0000	1.217
***************
*** 1691,1696 ****
  
  	new = type->tp_alloc(type, 0);
! 	if (new != NULL)
  		((PySocketSockObject *)new)->sock_fd = -1;
  	return new;
  }
--- 1691,1698 ----
  
  	new = type->tp_alloc(type, 0);
! 	if (new != NULL) {
  		((PySocketSockObject *)new)->sock_fd = -1;
+ 		((PySocketSockObject *)new)->errorhandler = &PySocket_Err;
+ 	}
  	return new;
  }