]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libcpp: Fix overly large buffer allocation
authorLewis Hyatt <lhyatt@gmail.com>
Tue, 22 Oct 2024 19:23:40 +0000 (15:23 -0400)
committerLewis Hyatt <lhyatt@gcc.gnu.org>
Tue, 24 Dec 2024 01:24:30 +0000 (20:24 -0500)
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.

libcpp/macro.cc

index 0b8eebee0610ae773bb9c279d4966b1340c37260..66c0bb031456d6ae51c6d55faf7ae727df54a19a 100644 (file)
@@ -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);
 }