diff --git a/CHANGES.md b/CHANGES.md index 8aafd1fa..3ca0859d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,6 +7,7 @@ Bug Fixes - Fix writing and reading of string columns with length 1 vectors in numpy 2. - Fix building against NumPy 2.3.0. + - Fix potential free of null pointer in stringlist_delete version 1.2.5 ------------- diff --git a/fitsio/fitsio_pywrap.c b/fitsio/fitsio_pywrap.c index 957643dd..e216db06 100644 --- a/fitsio/fitsio_pywrap.c +++ b/fitsio/fitsio_pywrap.c @@ -305,10 +305,12 @@ static struct stringlist* stringlist_delete(struct stringlist* slist) { size_t i=0; if (slist->data != NULL) { for (i=0; i < slist->size; i++) { - free(slist->data[i]); + if (slist->data[i] != NULL) { + free(slist->data[i]); + } } + free(slist->data); } - free(slist->data); free(slist); } return NULL;