https://gcc.gnu.org/g:27af1a14f3a0c897f5da3fc36cd2f9fe5ca4b0ed

commit r15-6430-g27af1a14f3a0c897f5da3fc36cd2f9fe5ca4b0ed
Author: Lewis Hyatt <lhy...@gmail.com>
Date:   Tue Oct 22 15:23:40 2024 -0400

    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.

Diff:
---
 libcpp/macro.cc | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/libcpp/macro.cc b/libcpp/macro.cc
index 0b8eebee0610..66c0bb031456 100644
--- a/libcpp/macro.cc
+++ b/libcpp/macro.cc
@@ -2579,10 +2579,8 @@ tokens_buff_new (cpp_reader *pfile, size_t len,
                 location_t **virt_locs)
 {
   size_t tokens_size = len * sizeof (cpp_token *);
-  size_t locs_size = len * sizeof (location_t);
-
   if (virt_locs != NULL)
-    *virt_locs = XNEWVEC (location_t, locs_size);
+    *virt_locs = XNEWVEC (location_t, len);
   return _cpp_get_buff (pfile, tokens_size);
 }

Reply via email to