On Wed, May 21, 2025 at 08:55:37AM +0200, Karel Zak wrote: > On Tue, May 20, 2025 at 04:24:07PM +0200, Stanislav Brabec wrote: > > Stanislav Brabec wrote: > > > As the whhole econf_file structure is freed by econf_free(file) at the end > > > > > of blkid_read_config, econf_file structure cannot be defined as static and > > > initialized only once. The econf_free() is not robust enough and keeps a > > > pointer to the garbage after the first call. And if /etc/blkid.conf does > > > not exist, it is called second time. > > > > However the patch is correct and fixes the crash, there are still open questions: > > > > - Why blkid_read_config() and econf_readConfig() are called twice with the same parameters? Is it intended behavior? > > This code pattern (e.g., libblkid/src/evaluate.c): > > conf = blkid_read_config(NULL); > ... > > cachefile = blkid_get_cache_filename(conf); > rc = blkid_get_cache(&c, cachefile); > > If blkid_get_cache_filename() returns NULL, then blkid_get_cache() > reads the configuration again. Additionally, blkid_get_cache_filename() can read the > configuration if 'conf' is NULL. > > Yes, it's not elegant. Added to TODO: https://github.com/util-linux/util-linux/issues/3580 -- Karel Zak <kzak@xxxxxxxxxx> http://karelzak.blogspot.com