[all-commits] [llvm/llvm-project] 995c4f: [demangler] Fix buffer growth

Nathan Sidwell via All-commits all-commits at lists.llvm.org
Mon Feb 14 03:59:54 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 995c4f306890ad379de19106f053238ce89f1483
      https://github.com/llvm/llvm-project/commit/995c4f306890ad379de19106f053238ce89f1483
  Author: Nathan Sidwell <nathan at acm.org>
  Date:   2022-02-14 (Mon, 14 Feb 2022)

  Changed paths:
    M libcxxabi/src/demangle/Utility.h
    M llvm/include/llvm/Demangle/Utility.h

  Log Message:
  -----------
  [demangler] Fix buffer growth

The output buffer growth algorithm had a few issues:

a) An off-by-one error in the initial size check, which uses
'>='. This error was safe, but could cause us to reallocate when there
was no need.

b) An inconsistency between the initial size check (>=) and the
post-doubling check (>).  The latter was somewhat obscured by the
swapped operands.

c) There would be many reallocs with an initially-small buffer.  Add a
little initialization hysteresis.

Reviewed By: ChuanqiXu

Differential Revision: https://reviews.llvm.org/D119177




More information about the All-commits mailing list