oops - self reference after MKOBJ may lead to trouble with garbage collector,
authorClaus Gittinger <cg@exept.de>
Fri, 18 Apr 1997 16:31:57 +0200
changeset 2560 d5b6c661718b
parent 2559 c1e87dd81a13
child 2561 205ee33decf9
oops - self reference after MKOBJ may lead to trouble with garbage collector, if self is not protected (NOCONTEXT primitive)
ExtStream.st
ExternalStream.st
--- a/ExtStream.st	Fri Apr 18 16:30:35 1997 +0200
+++ b/ExtStream.st	Fri Apr 18 16:31:57 1997 +0200
@@ -862,7 +862,10 @@
 	__isString(openMode) &&
 	(f = fdopen(__intVal(anInteger), __stringVal(openMode))) != 0
     ) {
-	__INST(filePointer) = fp = __MKOBJ((int)f); __STORE(self, fp);
+	__PROTECT__(self);
+	fp = __MKOBJ((int)f); 
+	__UNPROTECT__(self);
+	__INST(filePointer) = fp; __STORE(self, fp);
 	RETURN (self);
     }
 %}.
@@ -3748,6 +3751,6 @@
 !ExternalStream class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Attic/ExtStream.st,v 1.125 1997-03-29 14:23:40 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Attic/ExtStream.st,v 1.126 1997-04-18 14:31:57 cg Exp $'
 ! !
 ExternalStream initialize!
--- a/ExternalStream.st	Fri Apr 18 16:30:35 1997 +0200
+++ b/ExternalStream.st	Fri Apr 18 16:31:57 1997 +0200
@@ -862,7 +862,10 @@
 	__isString(openMode) &&
 	(f = fdopen(__intVal(anInteger), __stringVal(openMode))) != 0
     ) {
-	__INST(filePointer) = fp = __MKOBJ((int)f); __STORE(self, fp);
+	__PROTECT__(self);
+	fp = __MKOBJ((int)f); 
+	__UNPROTECT__(self);
+	__INST(filePointer) = fp; __STORE(self, fp);
 	RETURN (self);
     }
 %}.
@@ -3748,6 +3751,6 @@
 !ExternalStream class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/ExternalStream.st,v 1.125 1997-03-29 14:23:40 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ExternalStream.st,v 1.126 1997-04-18 14:31:57 cg Exp $'
 ! !
 ExternalStream initialize!