https://bugs.kde.org/show_bug.cgi?id=483372
Bug ID: 483372 Summary: Double calloc() not detected Classification: Developer tools Product: valgrind Version: 3.22.0 Platform: Fedora RPMs OS: Linux Status: REPORTED Severity: minor Priority: NOR Component: memcheck Assignee: jsew...@acm.org Reporter: nsldvndvjdv154sf5v4...@proton.me Target Milestone: --- I was using Valgrind with one of my compiled code, and it was telling me that an allocated block werent freed at the end of the program. After a bit of research, i found that a symbol were used with `calloc()` 2 times in different functions in the program. I reproduced the same erroneous situation in a simple way : ``` #include <stdio.h> #include <stdlib.h> int another_function(char **var) { *var = calloc(10, sizeof(char)); if (!*var) return -1; return 0; } int main(void) { char *var_one; // ... var_one = calloc(5, sizeof(char)); if (!var_one) { printf("Allocation error on var_one\n"); return -1; } // ... if (another_function(&var_one) == -1) { printf("Allocation error on var_one from another_function\n"); free(var_one); return -1; } free(var_one); return 0; } ``` Below is the Valgrind output, ran with `--leak-check=full` : ``` ==12661== Memcheck, a memory error detector ==12661== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al. ==12661== Using Valgrind-3.22.0 and LibVEX; rerun with -h for copyright info ==12661== Command: ./main ==12661== ==12661== ==12661== HEAP SUMMARY: ==12661== in use at exit: 5 bytes in 1 blocks ==12661== total heap usage: 2 allocs, 1 frees, 15 bytes allocated ==12661== ==12661== 5 bytes in 1 blocks are definitely lost in loss record 1 of 1 ==12661== at 0x4849E60: calloc (vg_replace_malloc.c:1595) ==12661== by 0x40119B: main (in main) ==12661== ==12661== LEAK SUMMARY: ==12661== definitely lost: 5 bytes in 1 blocks ==12661== indirectly lost: 0 bytes in 0 blocks ==12661== possibly lost: 0 bytes in 0 blocks ==12661== still reachable: 0 bytes in 0 blocks ==12661== suppressed: 0 bytes in 0 blocks ==12661== ==12661== For lists of detected and suppressed errors, rerun with: -s ==12661== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0) ``` I'm surprised that Valgrind didn't consider it as an error, i just wanted to know if this is a correct behaviour or not since i did not found any similar situation in QnA or any platform. -- You are receiving this mail because: You are watching all bug changes.