当前位置:网站首页>Debug:==42==ERROR: AddressSanitizer: heap-buffer-overflow on address

Debug:==42==ERROR: AddressSanitizer: heap-buffer-overflow on address

2022-07-04 10:15:00 Wildcraner

Encountered when brushing the buckle
 Insert picture description here


Error reason


for (int j = i; j < leng; j++){
    
     nums[j] = nums[j+1];
}

Here is the reason for the error : The address range of the array is exceeded
When j = leng when nums[j+1] = nums[leng+1] At this time, the maximum range of the array is nums[leng] and nums[leng+1] It doesn't exist


Suggest to modify


for (int j = i -1; j < leng; j++){
    
     nums[j -1] = nums[j];
}
原网站

版权声明
本文为[Wildcraner]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202141422452519.html