[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gawk 3.1.4: don't read past EOF
From: |
Andreas Schwab |
Subject: |
gawk 3.1.4: don't read past EOF |
Date: |
Sun, 19 Sep 2004 23:55:47 +0200 |
When an awk script that is big enough to fill more than a buffer's worth
does not end with a newline then nextc reads past EOF.
Andreas.
2004-09-19 Andreas Schwab <address@hidden>
* awkgram.y (nextc): Check for end of lexer buffer before
advancing ring buffer index.
--- gawk-3.1.4/awkgram.y.~1~ 2004-07-26 16:11:12.000000000 +0200
+++ gawk-3.1.4/awkgram.y 2004-09-19 21:39:57.203777936 +0200
@@ -1433,6 +1433,11 @@ static int
nextc(void)
{
if (gawk_mb_cur_max > 1) {
+ if (!lexptr || lexptr >= lexend)
+ if (!get_src_buf()) {
+ return EOF;
+ }
+
/* Update the buffer index. */
cur_ring_idx = (cur_ring_idx == RING_BUFFER_SIZE - 1)? 0 :
cur_ring_idx + 1;
@@ -1444,11 +1449,6 @@ nextc(void)
mbstate_t tmp_state;
size_t mbclen;
- if (!lexptr || lexptr >= lexend)
- if (!get_src_buf()) {
- return EOF;
- }
-
for (idx = 0 ; lexptr + idx < lexend ; idx++) {
tmp_state = cur_mbstate;
mbclen = mbrlen(lexptr, idx + 1, &tmp_state);
--
Andreas Schwab, SuSE Labs, address@hidden
SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
- gawk 3.1.4: don't read past EOF,
Andreas Schwab <=