From: Jan Dubois Date: Mon, 16 Nov 2009 22:43:20 +0000 (-0800) Subject: Fix crash in refactored lexer internals X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=490354310ada83dc35c6cfd9dd59ad62781fcaf7;p=p5sagit%2Fp5-mst-13.2.git Fix crash in refactored lexer internals Commit f0e67a1d29102aa9905aecf2b0f98449697d5af3 changed the control flow so that PerlIO_tell(PL_rsfp) could be called when PL_rsfp was NULL, which produces a crash at least on Windows with the MSVCRT runtime. This change moves the detection if PL_rsfp is NULL or not closer to the location where is is actually tested, which gets rid of the crashes. I however have *not* verified if the changes in control flow in f0e67a1d are otherwise correct or not. --- diff --git a/toke.c b/toke.c index 6793f7b..6b5ef4f 100644 --- a/toke.c +++ b/toke.c @@ -4315,7 +4315,6 @@ Perl_yylex(pTHX) } do { U32 fake_eof = 0; - bof = PL_rsfp ? TRUE : FALSE; if (0) { fake_eof: fake_eof = LEX_FAKE_EOF; @@ -4332,6 +4331,7 @@ Perl_yylex(pTHX) s = PL_bufptr; /* If it looks like the start of a BOM or raw UTF-16, * check if it in fact is. */ + bof = PL_rsfp ? TRUE : FALSE; if (bof && (*s == 0 || *(U8*)s == 0xEF ||