If flowf is NULL then fclose(spif) must be called.
Split up the error check from if (spif == NULL || flowf == NULL) to
individual checks since that is easier to read.
Noticed by markus@, OK tb@
-/* $OpenBSD: ikev2.c,v 1.368 2023/06/12 09:02:31 claudio Exp $ */
+/* $OpenBSD: ikev2.c,v 1.369 2023/06/13 08:45:41 claudio Exp $ */
/*
* Copyright (c) 2019 Tobias Heider <tobias.heider@stusta.de>
int ret = -1;
spif = open_memstream(&spibuf, &spisz);
+ if (spif == NULL) {
+ log_warn("%s", __func__);
+ return (ret);
+ }
flowf = open_memstream(&flowbuf, &flowsz);
- if (spif == NULL || flowf == NULL) {
+ if (flowf == NULL) {
log_warn("%s", __func__);
+ fclose(spif);
return (ret);
}