BUG/MINOR: pattern: release the reference on failure to load from file

In pattern_read_from_file(), in case of failure to load from the file,
the newly allocated reference remains attached to the list and is never
freed. Let's just do it.

This can be backported to all versions since it arrived in 1.5 with
commit 1e00d3853b ("MAJOR: pattern/map: Extends the map edition system
in the patterns").
This commit is contained in:
Willy Tarreau 2026-04-30 16:27:36 +02:00
parent ecb901ff6c
commit dc93168f22

View File

@ -2590,12 +2590,18 @@ int pattern_read_from_file(struct pattern_head *head, unsigned int refflags,
if (ref->flags & PAT_REF_FILE) {
if (load_smp) {
ref->flags |= PAT_REF_SMP;
if (!pat_ref_read_from_file_smp(ref, err))
if (!pat_ref_read_from_file_smp(ref, err)) {
LIST_DELETE(&ref->list);
pat_ref_free(ref);
return 0;
}
}
else {
if (!pat_ref_read_from_file(ref, err))
if (!pat_ref_read_from_file(ref, err)) {
LIST_DELETE(&ref->list);
pat_ref_free(ref);
return 0;
}
}
}
else if ((ref->flags & PAT_REF_ID) && load_smp)