https://github.com/jsji created https://github.com/llvm/llvm-project/pull/129971
None >From 801d92357366d95bc5bd044125eefc25862b6fee Mon Sep 17 00:00:00 2001 From: Jinsong Ji <jinsong...@intel.com> Date: Wed, 5 Mar 2025 17:54:48 -0800 Subject: [PATCH] [NFC][c-index-test] factor data len out --- clang/tools/c-index-test/c-index-test.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/clang/tools/c-index-test/c-index-test.c b/clang/tools/c-index-test/c-index-test.c index 50f32c0a20e5a..1ad2e44aae3f7 100644 --- a/clang/tools/c-index-test/c-index-test.c +++ b/clang/tools/c-index-test/c-index-test.c @@ -3554,13 +3554,11 @@ static CXIdxClientContainer makeClientContainer(CXClientData *client_data, clang_indexLoc_getFileLocation(loc, &file, 0, &line, &column, 0); - len = sizeof(IndexDataStringList) + strlen(name) + digitCount(line) + - digitCount(column) + 3; - node = (IndexDataStringList *)malloc(len); + datalen = strlen(name) + digitCount(line) + digitCount(column) + 3; + node = (IndexDataStringList *)malloc(len + sizeof(IndexDataStringList)); assert(node); newStr = node->data; - snprintf(newStr, len - sizeof(IndexDataStringList), "%s:%d:%d", name, line, - column); + snprintf(newStr, datalen, "%s:%d:%d", name, line, column); /* Remember string so it can be freed later. */ index_data = (IndexData *)client_data; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits