diff options
-rw-r--r-- | ext/tidy/tidy.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/ext/tidy/tidy.c b/ext/tidy/tidy.c index 7a87300a7e..ec0151e8ca 100644 --- a/ext/tidy/tidy.c +++ b/ext/tidy/tidy.c @@ -497,13 +497,15 @@ static void tidy_object_free_storage(void *object TSRMLS_DC) zend_hash_destroy(intern->std.properties); FREE_HASHTABLE(intern->std.properties); - intern->ptdoc->ref_count--; - - if (intern->ptdoc->ref_count <= 0) { - tidyBufFree(intern->ptdoc->errbuf); - efree(intern->ptdoc->errbuf); - tidyRelease(intern->ptdoc->doc); - efree(intern->ptdoc); + if (intern->ptdoc) { + intern->ptdoc->ref_count--; + + if (intern->ptdoc->ref_count <= 0) { + tidyBufFree(intern->ptdoc->errbuf); + efree(intern->ptdoc->errbuf); + tidyRelease(intern->ptdoc->doc); + efree(intern->ptdoc); + } } efree(object); |