This is the mail archive of the gdb-testers@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb/gdb-8.3-branch] Avoid a crash in source_cache::extract_lines


*** TEST RESULTS FOR COMMIT 655aeea04784cdc3e4dfbc0801e7be56f9a1ec11 ***

Author: Tom Tromey <tromey@adacore.com>
Branch: gdb-8.3-branch
Commit: 655aeea04784cdc3e4dfbc0801e7be56f9a1ec11

Avoid a crash in source_cache::extract_lines

If the first requested line is larger than the number of lines in the
source buffer, source_cache::extract_lines could crash, because it
would try to pass string::npos" to string::substr.

This patch avoids the crash by checking for this case.

This version of the patch changes get_source_lines to return
std::string.

2019-03-14  Tom Tromey  <tromey@adacore.com>

	* source-cache.h (class source_cache) <get_source_lines>: Return
	std::string.
	* source-cache.c (source_cache::extract_lines): Handle case where
	first_pos==npos.  Return std::string.
	(source_cache::get_source_lines): Update.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]