File pacemaker-libcrmcommon-avoid-memory-leak-when-schema-transform-not-found.patch of Package pacemaker.openSUSE_Leap_42.3_Update
commit d2c2bf04693899dcfe79be024faf72f02adfb419
Author: Ken Gaillot <kgaillot@redhat.com>
Date: Fri Mar 2 09:48:28 2018 -0600
Low: libcrmcommon: avoid memory leak when schema transform not found
Index: pacemaker-1.1.16+20170320.77ea74d/lib/common/schemas.c
===================================================================
--- pacemaker-1.1.16+20170320.77ea74d.orig/lib/common/schemas.c
+++ pacemaker-1.1.16+20170320.77ea74d/lib/common/schemas.c
@@ -276,7 +276,6 @@ crm_schema_init(void)
// Shouldn't be possible, but makes static analysis happy
crm_err("Skipping schema '%s': could not parse version",
namelist[lpc]->d_name);
- free(namelist[lpc]);
continue;
}
if ((lpc + 1) < max) {
@@ -305,16 +304,19 @@ crm_schema_init(void)
next = -1;
}
__xml_schema_add(2, version, NULL, NULL, transform, next);
- free(namelist[lpc]);
free(transform);
}
+
+ for (lpc = 0; lpc < max; lpc++) {
+ free(namelist[lpc]);
+ }
+ free(namelist);
}
/* 1.1 was the old name for -next */
__xml_schema_add(2, zero, "pacemaker-1.1", "pacemaker-next.rng", NULL, 0);
__xml_schema_add(2, zero, "pacemaker-next", "pacemaker-next.rng", NULL, -1);
__xml_schema_add(0, zero, "none", "N/A", NULL, -1);
- free(namelist);
}
static gboolean