From e66eddd1d554c12a52497476fb79efde112de576 Mon Sep 17 00:00:00 2001 From: yancey Date: Sat, 22 Jul 2023 14:00:03 -0400 Subject: [PATCH] fix mem access problem reported by sanitizer --- CMakeLists.txt | 2 +- common.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d84d982..b79c4d7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ #note: experimental -# currently only used for generating `compile_commands.json` for clangd +# currently only used for generating `compile_commands.json` for clangd. # to build this project, it's suggested to use `makefile` instead cmake_minimum_required(VERSION 3.7) diff --git a/common.cpp b/common.cpp index ffcddde..3d822ba 100644 --- a/common.cpp +++ b/common.cpp @@ -1127,8 +1127,8 @@ void print_binary_chars(const char *a, int len) { u32_t djb2(unsigned char *str, int len) { u32_t hash = 5381; int c; - int i = 0; - while (c = *str++, i++ != len) { + for (int i=0; i