Skip to content

Commit 27af1a1

Browse files
Lewis HyattLewis Hyatt
authored andcommitted
libcpp: Fix overly large buffer allocation
It seems that tokens_buff_new() has always been allocating the virtual location buffer 4 times larger than intended, and now that location_t is 64-bit, it is 8 times larger. Fixed. libcpp/ChangeLog: * macro.cc (tokens_buff_new): Fix length argument to XNEWVEC.
1 parent 11090da commit 27af1a1

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

libcpp/macro.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2579,10 +2579,8 @@ tokens_buff_new (cpp_reader *pfile, size_t len,
25792579
location_t **virt_locs)
25802580
{
25812581
size_t tokens_size = len * sizeof (cpp_token *);
2582-
size_t locs_size = len * sizeof (location_t);
2583-
25842582
if (virt_locs != NULL)
2585-
*virt_locs = XNEWVEC (location_t, locs_size);
2583+
*virt_locs = XNEWVEC (location_t, len);
25862584
return _cpp_get_buff (pfile, tokens_size);
25872585
}
25882586

0 commit comments

Comments
 (0)