SQLite Forum

memory leaks in sqlite3.c:23545
Login
the the ASAN logs on the state-of-the-art version 3.32.1 2020-05-25 16:19:56 are as follows:



=================================================================
==2164==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 104 byte(s) in 1 object(s) allocated from:

    #0 0x7ffff6f02602 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98602)
    #1 0x462874 in sqlite3MemMalloc /data3/ASAN2/sqlite-src-3320100/ASAN/sqlite3.c:23627
    #2 0x4637ab in mallocWithAlarm /data3/ASAN2/sqlite-src-3320100/ASAN/sqlite3.c:27519
    #3 0x4638f0 in sqlite3Malloc /data3/ASAN2/sqlite-src-3320100/ASAN/sqlite3.c:27549
    #4 0x464081 in sqlite3Realloc /data3/ASAN2/sqlite-src-3320100/ASAN/sqlite3.c:27719
    #5 0x46423e in sqlite3_realloc64 /data3/ASAN2/sqlite-src-3320100/ASAN/sqlite3.c:27778
    #6 0x43b0b2 in import_append_char /data3/ASAN2/sqlite-src-3320100/ASAN/shell.c:13283
    #7 0x44bf9c in do_meta_command /data3/ASAN2/sqlite-src-3320100/ASAN/shell.c:16507
    #8 0x457078 in process_input /data3/ASAN2/sqlite-src-3320100/ASAN/shell.c:18718
    #9 0x459a68 in main /data3/ASAN2/sqlite-src-3320100/ASAN/shell.c:19529
    #10 0x7ffff648582f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)

SUMMARY: AddressSanitizer: 104 byte(s) leaked in 1 allocation(s).











The relevant codes in sqlite3.c:

```
static void *sqlite3MemMalloc(int nByte){
#ifdef SQLITE_MALLOCSIZE
  void *p;
  testcase( ROUND8(nByte)==nByte );
  p = SQLITE_MALLOC( nByte );                  \\ line 23627
  if( p==0 ){
    testcase( sqlite3GlobalConfig.xLog!=0 );
    sqlite3_log(SQLITE_NOMEM, "failed to allocate %u bytes of memory", nByte);
  }
  return p;
#else
  sqlite3_int64 *p;
  assert( nByte>0 );
  testcase( ROUND8(nByte)!=nByte );
  p = SQLITE_MALLOC( nByte+8 );
  if( p ){
    p[0] = nByte;
    p++;
  }else{
    testcase( sqlite3GlobalConfig.xLog!=0 );
    sqlite3_log(SQLITE_NOMEM, "failed to allocate %u bytes of memory", nByte);
  }
  return (void *)p;
#endif
}
```