Fix mem leak in config file parser
This fixes the following leaks: ==18690== 256 bytes in 1 blocks are definitely lost in loss record 75 of 100 ==18690== at 0x4C28BED: malloc (vg_replace_malloc.c:263) ==18690== by 0x511613F: regcomp (regcomp.c:487) ==18690== by 0x4E34313: conf_parse_file (in /usr/lib/x86_64-linux-gnu/libnfc.so.4.0.0) ==18690== by 0x4E349F5: conf_devices_load.constprop.1 (in /usr/lib/x86_64-linux-gnu/libnfc.so.4.0.0) ==18690== by 0x4E362C0: nfc_context_new (in /usr/lib/x86_64-linux-gnu/libnfc.so.4.0.0) ==18690== by 0x4E34D08: nfc_init (in /usr/lib/x86_64-linux-gnu/libnfc.so.4.0.0) ==18690== ==18690== 32,068 (224 direct, 31,844 indirect) bytes in 1 blocks are definitely lost in loss record 98 of 100 ==18690== at 0x4C28BED: malloc (vg_replace_malloc.c:263) ==18690== by 0x4C28D6F: realloc (vg_replace_malloc.c:632) ==18690== by 0x5115DF3: re_compile_internal (regcomp.c:760) ==18690== by 0x51161AB: regcomp (regcomp.c:506) ==18690== by 0x4E34313: conf_parse_file (in /usr/lib/x86_64-linux-gnu/libnfc.so.4.0.0) ==18690== by 0x4E349F5: conf_devices_load.constprop.1 (in /usr/lib/x86_64-linux-gnu/libnfc.so.4.0.0) ==18690== by 0x4E362C0: nfc_context_new (in /usr/lib/x86_64-linux-gnu/libnfc.so.4.0.0) ==18690== by 0x4E34D08: nfc_init (in /usr/lib/x86_64-linux-gnu/libnfc.so.4.0.0)
This commit is contained in:
parent
9dcf7378b6
commit
3d9ebb5044
1 changed files with 2 additions and 0 deletions
|
@ -66,6 +66,7 @@ conf_parse_file(const char *filename, void (*conf_keyvalue)(void *data, const ch
|
||||||
regmatch_t *pmatch = malloc(sizeof(*pmatch) * nmatch);
|
regmatch_t *pmatch = malloc(sizeof(*pmatch) * nmatch);
|
||||||
if (!pmatch) {
|
if (!pmatch) {
|
||||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "%s", "Not enough memory: malloc failed.");
|
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "%s", "Not enough memory: malloc failed.");
|
||||||
|
regfree(&preg);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,6 +99,7 @@ conf_parse_file(const char *filename, void (*conf_keyvalue)(void *data, const ch
|
||||||
}
|
}
|
||||||
|
|
||||||
free(pmatch);
|
free(pmatch);
|
||||||
|
regfree(&preg);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue