]> granicus.if.org Git - python/commit
[2.7] bpo-29854: Fix segfault in call_readline() (GH-728)
authorNir Soffer <nirsof@gmail.com>
Mon, 10 Jul 2017 21:06:57 +0000 (00:06 +0300)
committerBerker Peksag <berker.peksag@gmail.com>
Mon, 10 Jul 2017 21:06:57 +0000 (00:06 +0300)
commitbfa4fe4f39dd8b5ce1a0b649cedd36857859081a
treeb79e7729a80f367da8169294ccf39fcad248d2e6
parent5d1554a2eb00938f3d5a3e18b6244dd023fc9339
[2.7] bpo-29854: Fix segfault in call_readline() (GH-728)

If history-length is set in .inputrc, and the history file is double the
history size (or more), history_get(N) returns NULL, and python
segfaults. Fix that by checking for NULL return value.

It seems that the root cause is incorrect handling of bigger history in
readline, but Python should not segfault even if readline returns
unexpected value.

This issue affects only GNU readline. When using libedit emulation
system history size option does not work.

This is a backport of the actual fix from master without the test, since
the test depends on new run_pty() helper which is not available in 2.7.
Misc/NEWS.d/next/Library/2017-07-07-02-18-57.bpo-29854.J8wKb_.rst [new file with mode: 0644]
Modules/readline.c