From b83308461bf4864b00290376a67168f2c303c219 Mon Sep 17 00:00:00 2001 From: Omar Kallel Date: Wed, 30 Jun 2021 10:31:53 +0100 Subject: [PATCH] Fix segmentation fault in case the backup tree is not initialized --- backupSession.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/backupSession.c b/backupSession.c index 7606633..2e30c23 100644 --- a/backupSession.c +++ b/backupSession.c @@ -172,7 +172,8 @@ void bkp_tree_clean(void) void bkp_session_save() { FILE *fp; - + if (!bkp_tree) + return; pthread_mutex_lock(&mutex_backup_session); fp = fopen(CWMP_BKP_FILE, "w"); mxmlSaveFile(bkp_tree, fp, MXML_NO_CALLBACK); @@ -200,7 +201,8 @@ mxml_node_t *bkp_session_node_found(mxml_node_t *tree, char *name, struct search mxml_node_t *b = tree, *c, *d; struct search_keywords; int i = 0; - + if (!tree) + return NULL; b = mxmlFindElement(b, b, name, NULL, NULL, MXML_DESCEND_FIRST); while (b) { if (b && b->child) {