diff --git a/zathura/document.c b/zathura/document.c index 29781b6..8fed1a3 100644 --- a/zathura/document.c +++ b/zathura/document.c @@ -94,15 +94,20 @@ zathura_document_open(zathura_plugin_manager_t* plugin_manager, const char* } plugin = zathura_plugin_manager_get_plugin(plugin_manager, content_type); - g_free((void*)content_type); - content_type = NULL; if (plugin == NULL) { girara_error("Unknown file type: '%s'", content_type); check_set_error(error, ZATHURA_ERROR_UNKNOWN); + + g_free((void*)content_type); + content_type = NULL; + goto error_free; } + g_free((void*)content_type); + content_type = NULL; + document = g_try_malloc0(sizeof(zathura_document_t)); if (document == NULL) { check_set_error(error, ZATHURA_ERROR_OUT_OF_MEMORY);