oops - nextChunk could access invalid memory due
to GC moving its buffer.
--- a/ExtStream.st Wed Aug 20 10:53:48 1997 +0200
+++ b/ExtStream.st Wed Aug 20 16:45:54 1997 +0200
@@ -10,8 +10,6 @@
hereby transferred.
"
-'From Smalltalk/X, Version:3.1.9 on 19-aug-1997 at 10:14:54' !
-
ReadWriteStream subclass:#ExternalStream
instanceVariableNames:'filePointer mode buffered binary useCRLF hitEOF didWrite
lastErrorNumber readAhead'
@@ -2899,7 +2897,7 @@
%{ /* STACK: 12000 */
/*
* the main trick (and a bit of complication) here
- * is to read the first 7k into a stack-buffer.
+ * is to read the first 8k into a stack-buffer.
* Since most chunks fit into that,
* this avoids creating lots of garbage for thos small chunks.
*/
@@ -2908,7 +2906,7 @@
unsigned char c, lastC, peekC;
int ret;
unsigned char *bufferPtr = (unsigned char *)0;
- unsigned char fastBuffer[7000];
+ unsigned char fastBuffer[8000];
REGISTER int index;
int currSize, fastFlag, _buffered;
int atBeginOfLine = 1, inPrimitive = 0;
@@ -2984,12 +2982,6 @@
break;
}
}
- if (!fastFlag) {
- /*
- * old buffer may have moved - refetch pointer
- */
- bufferPtr = __stringVal(buffer);
- }
/*
* do we have to resize the buffer ?
@@ -2999,6 +2991,12 @@
unsigned char *nbp;
newBuffer = __MKEMPTYSTRING(currSize * 2);
+ if (!fastFlag) {
+ /*
+ * refetch - buffer could be moved by GC
+ */
+ bufferPtr = __stringVal(buffer);
+ }
if (newBuffer == nil) {
/*
* mhmh - chunk seems to be very big ....
@@ -3015,6 +3013,14 @@
currSize = currSize * 2;
}
+ if (!fastFlag) {
+ /*
+ * old buffer may have moved (interrupt while reading)
+ * - refetch pointer
+ */
+ bufferPtr = __stringVal(buffer);
+ }
+
/*
* filter out cr-nl; make it nl
*/
@@ -3931,6 +3937,6 @@
!ExternalStream class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Attic/ExtStream.st,v 1.137 1997-08-19 09:16:52 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Attic/ExtStream.st,v 1.138 1997-08-20 14:45:54 cg Exp $'
! !
ExternalStream initialize!
--- a/ExternalStream.st Wed Aug 20 10:53:48 1997 +0200
+++ b/ExternalStream.st Wed Aug 20 16:45:54 1997 +0200
@@ -10,8 +10,6 @@
hereby transferred.
"
-'From Smalltalk/X, Version:3.1.9 on 19-aug-1997 at 10:14:54' !
-
ReadWriteStream subclass:#ExternalStream
instanceVariableNames:'filePointer mode buffered binary useCRLF hitEOF didWrite
lastErrorNumber readAhead'
@@ -2899,7 +2897,7 @@
%{ /* STACK: 12000 */
/*
* the main trick (and a bit of complication) here
- * is to read the first 7k into a stack-buffer.
+ * is to read the first 8k into a stack-buffer.
* Since most chunks fit into that,
* this avoids creating lots of garbage for thos small chunks.
*/
@@ -2908,7 +2906,7 @@
unsigned char c, lastC, peekC;
int ret;
unsigned char *bufferPtr = (unsigned char *)0;
- unsigned char fastBuffer[7000];
+ unsigned char fastBuffer[8000];
REGISTER int index;
int currSize, fastFlag, _buffered;
int atBeginOfLine = 1, inPrimitive = 0;
@@ -2984,12 +2982,6 @@
break;
}
}
- if (!fastFlag) {
- /*
- * old buffer may have moved - refetch pointer
- */
- bufferPtr = __stringVal(buffer);
- }
/*
* do we have to resize the buffer ?
@@ -2999,6 +2991,12 @@
unsigned char *nbp;
newBuffer = __MKEMPTYSTRING(currSize * 2);
+ if (!fastFlag) {
+ /*
+ * refetch - buffer could be moved by GC
+ */
+ bufferPtr = __stringVal(buffer);
+ }
if (newBuffer == nil) {
/*
* mhmh - chunk seems to be very big ....
@@ -3015,6 +3013,14 @@
currSize = currSize * 2;
}
+ if (!fastFlag) {
+ /*
+ * old buffer may have moved (interrupt while reading)
+ * - refetch pointer
+ */
+ bufferPtr = __stringVal(buffer);
+ }
+
/*
* filter out cr-nl; make it nl
*/
@@ -3931,6 +3937,6 @@
!ExternalStream class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/ExternalStream.st,v 1.137 1997-08-19 09:16:52 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/ExternalStream.st,v 1.138 1997-08-20 14:45:54 cg Exp $'
! !
ExternalStream initialize!