... | ... |
@@ -178,7 +178,7 @@ static int stirshaken_handle_cache_to_disk(X509 *x, STACK_OF(X509) *xchain, cons |
178 | 178 |
w = PEM_write_X509(fp, x); |
179 | 179 |
if (w == 0) { |
180 | 180 |
LM_ERR("Failed to write cert to %s", cert_full_path); |
181 |
- return -1; |
|
181 |
+ goto fail; |
|
182 | 182 |
} |
183 | 183 |
|
184 | 184 |
for (i = 0; i < sk_X509_num(xchain); i++) { |
... | ... |
@@ -187,7 +187,7 @@ static int stirshaken_handle_cache_to_disk(X509 *x, STACK_OF(X509) *xchain, cons |
187 | 187 |
w = PEM_write_X509(fp, xc); |
188 | 188 |
if (w == 0) { |
189 | 189 |
LM_ERR("Failed to write chain to %s", cert_full_path); |
190 |
- return -1; |
|
190 |
+ goto fail; |
|
191 | 191 |
} |
192 | 192 |
} |
193 | 193 |
|
... | ... |
@@ -195,6 +195,10 @@ static int stirshaken_handle_cache_to_disk(X509 *x, STACK_OF(X509) *xchain, cons |
195 | 195 |
fp = NULL; |
196 | 196 |
|
197 | 197 |
return 0; |
198 |
+ |
|
199 |
+fail: |
|
200 |
+ if (fp) fclose(fp); |
|
201 |
+ return -1; |
|
198 | 202 |
} |
199 | 203 |
|
200 | 204 |
static int stirshaken_handle_cache_from_disk(stir_shaken_context_t *ss, stir_shaken_cert_t *cert, const char *name) |