From f785c7de29870e14ac3598332341be0a69f0e4f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ne=C4=8Dada?= Date: Sun, 3 Mar 2019 00:43:40 +0000 Subject: [PATCH] Avoid NULL dereference in free() Former-commit-id: d257e5a0bfde5c4f6a6d7380eace24feba518b06 --- qpms/scatsystem.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/qpms/scatsystem.c b/qpms/scatsystem.c index 48ef24e..05eb614 100644 --- a/qpms/scatsystem.c +++ b/qpms/scatsystem.c @@ -485,14 +485,16 @@ qpms_scatsys_t *qpms_scatsys_apply_symmetry(const qpms_scatsys_t *orig, const qp void qpms_scatsys_free(qpms_scatsys_t *ss) { - free(ss->tm); - free(ss->p); - free(ss->fecv_pstarts); - free(ss->tm_sym_map); - free(ss->p_sym_map); - free(ss->otspace); - free(ss->p_orbitinfo); - free(ss->orbit_types); + if(ss) { + free(ss->tm); + free(ss->p); + free(ss->fecv_pstarts); + free(ss->tm_sym_map); + free(ss->p_sym_map); + free(ss->otspace); + free(ss->p_orbitinfo); + free(ss->orbit_types); + } free(ss); }