! Read the GRIB2 message from the file.
if (lgrib .gt. currlen) then
if (allocated(cgrib)) deallocate(cgrib)
allocate(cgrib(lgrib), stat = is)
currlen = lgrib
endif
Note that character buffer cgrib is allocated.
It is never deallocated. This causes a memory leak:
=================================================================
==16420==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 22643 byte(s) in 1 object(s) allocated from:
#0 0x7f45c7264c47 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
#1 0x560aaf93645a in degrib2 /home/ed/NCEPLIBS-grib_util/src/degrib2/degrib2.F90:66
#2 0x560aaf93b3c7 in main /home/ed/NCEPLIBS-grib_util/src/degrib2/degrib2.F90:15
#3 0x7f45c6a25082 in __libc_start_main ../csu/libc-start.c:308
SUMMARY: AddressSanitizer: 22643 byte(s) leaked in 1 allocation(s).
In degrib2.F90 we have:
Note that character buffer cgrib is allocated.
It is never deallocated. This causes a memory leak: