PR23940, check bounds before using

PR gas/23940
	* macro.c (getstring): Check array bound before accessing.
This commit is contained in:
Wu Heng
2019-01-25 13:41:47 +10:30
committed by Alan Modra
parent 0417426340
commit 10c172ba93
2 changed files with 7 additions and 2 deletions

View File

@@ -1,3 +1,8 @@
2019-01-25 Wu Heng <wu.heng@zte.com.cn>
PR gas/23940
* macro.c (getstring): Check array bound before accessing.
2019-01-25 Alan Modra <amodra@gmail.com> 2019-01-25 Alan Modra <amodra@gmail.com>
PR 20902 PR 20902

View File

@@ -285,8 +285,8 @@ getstring (size_t idx, sb *in, sb *acc)
{ {
int nest = 0; int nest = 0;
idx++; idx++;
while ((in->ptr[idx] != '>' || nest) while (idx < in->len
&& idx < in->len) && (in->ptr[idx] != '>' || nest))
{ {
if (in->ptr[idx] == '!') if (in->ptr[idx] == '!')
{ {