Resource leak in persist_read.c

Reason: In lines 435 and 439, the function returns without calling closing
fptr which was opened at line 399.

Fix: I added fclose(fptr) statements before each of the returns.
Signed-off-by: Panagiotis Vasilikos <panagiotis.vasilikos@alexandra.dk>
This commit is contained in:
Panagiotis Vasilikos 2020-01-29 13:30:24 +01:00
parent adb6f3a39d
commit 618413e1d2

View File

@ -4,12 +4,12 @@ Copyright (c) 2010-2018 Roger Light <roger@atchoo.org>
All rights reserved. This program and the accompanying materials All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0 are made available under the terms of the Eclipse Public License v1.0
and Eclipse Distribution License v1.0 which accompany this distribution. and Eclipse Distribution License v1.0 which accompany this distribution.
The Eclipse Public License is available at The Eclipse Public License is available at
http://www.eclipse.org/legal/epl-v10.html http://www.eclipse.org/legal/epl-v10.html
and the Eclipse Distribution License is available at and the Eclipse Distribution License is available at
http://www.eclipse.org/org/documents/edl-v10.php. http://www.eclipse.org/org/documents/edl-v10.php.
Contributors: Contributors:
Roger Light - initial implementation and documentation. Roger Light - initial implementation and documentation.
*/ */
@ -432,10 +432,12 @@ int persist__restore(struct mosquitto_db *db)
case DB_CHUNK_CFG: case DB_CHUNK_CFG:
if(db_version == 5){ if(db_version == 5){
if(persist__chunk_cfg_read_v5(fptr, &cfg_chunk)){ if(persist__chunk_cfg_read_v5(fptr, &cfg_chunk)){
fclose(fptr);
return 1; return 1;
} }
}else{ }else{
if(persist__chunk_cfg_read_v234(fptr, &cfg_chunk)){ if(persist__chunk_cfg_read_v234(fptr, &cfg_chunk)){
fclose(fptr);
return 1; return 1;
} }
} }