]> git.eshelyaron.com Git - emacs.git/commit
* src/lread.c (infile): Set/reset it like a dynamically scoped variable
authorStefan Monnier <monnier@iro.umontreal.ca>
Wed, 31 Jul 2019 15:19:39 +0000 (11:19 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Wed, 31 Jul 2019 15:19:39 +0000 (11:19 -0400)
commitbedcc2d87bde06482ccdc31ac7f428cbde34ced5
tree910a94845677f276e95fcc2ea0428ab951741d6d
parent495d0667fcf4df9f10c261684162c64f08aadd71
* src/lread.c (infile): Set/reset it like a dynamically scoped variable

I've seen segfaults where `infile` is nil when we get to
readbyte_from_file, presumably because Fload set it to NULL (via
close_infile_unwind) just before returning to its caller which was
probably itself within another read/load and for some reason
readevalloop didn't get to re-set `infile` like it used to do at every
iteration.  I was not able to really track down the bug, but the way
`infile` was set/reset seemed fragile and managing it like a standard
dynamically-scoped var seems both safer (and more efficient since we
don't need readevalloop to constantly re-set it).

(readchar): Assert that `infile` is set if using a function the depends on it.
(readbyte_from_file): Assert that `infile` is set.
(close_infile_unwind): Reset `infile` to its previous value rather than
to NULL.
(Fload): Remember the previous value of `infile` before chaning it.
(readevalloop): Don't set `infile` any more.
src/lread.c