From ccfc0e751610780311624b916bb39dcf76e940b1 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Wed, 28 Mar 2007 22:56:54 +0000 Subject: Fix abort on attempted destruction of CONTENT_DIRECTORY (1690222) svn path=/trunk/netsurf/; revision=3228 --- render/directory.c | 57 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 22 deletions(-) (limited to 'render/directory.c') diff --git a/render/directory.c b/render/directory.c index c64d05a77..e4b5b800d 100644 --- a/render/directory.c +++ b/render/directory.c @@ -34,8 +34,8 @@ bool directory_create(struct content *c, const char *params[]) { /* html_create() must have broadcast MSG_ERROR already, so we * don't need to. */ return false; - htmlParseChunk(c->data.html.parser, header, sizeof(header) - 1, 0); - return true; + htmlParseChunk(c->data.html.parser, header, sizeof(header) - 1, 0); + return true; } bool directory_convert(struct content *c, int width, int height) { @@ -59,22 +59,22 @@ bool directory_convert(struct content *c, int width, int height) { if (!nice_path) { msg_data.error = messages_get("MiscErr"); content_broadcast(c, CONTENT_MSG_ERROR, msg_data); - return false; + return false; } for (cnv = nice_path, tmp = path; *tmp != '\0'; *tmp++) { - if (*tmp == '<') { - *cnv++ = '&'; - *cnv++ = 'l'; - *cnv++ = 't'; - *cnv++ = ';'; - } else if (*tmp == '>') { - *cnv++ = '&'; - *cnv++ = 'g'; - *cnv++ = 't'; - *cnv++ = ';'; - } else { - *cnv++ = *tmp; - } + if (*tmp == '<') { + *cnv++ = '&'; + *cnv++ = 'l'; + *cnv++ = 't'; + *cnv++ = ';'; + } else if (*tmp == '>') { + *cnv++ = '&'; + *cnv++ = 'g'; + *cnv++ = 't'; + *cnv++ = ';'; + } else { + *cnv++ = *tmp; + } } *cnv++ = '\0'; snprintf(buffer, sizeof(buffer), "Index of %s\n\n" @@ -85,20 +85,20 @@ bool directory_convert(struct content *c, int width, int height) { res = url_parent(c->url, &up); if (res == URL_FUNC_OK) { - res = url_compare(c->url, up, &compare); - if (!compare) { + res = url_compare(c->url, up, &compare); + if (!compare) { snprintf(buffer, sizeof(buffer), "[..]\n"); htmlParseChunk(c->data.html.parser, buffer, strlen(buffer), 0); - } - free(up); - } + } + free(up); + } if ((parent = opendir(path)) == NULL) { msg_data.error = messages_get("EmptyErr"); content_broadcast(c, CONTENT_MSG_ERROR, msg_data); - return false; + return false; } while ((entry = readdir(parent)) != NULL) { if (!strcmp(entry->d_name, ".") || @@ -115,3 +115,16 @@ bool directory_convert(struct content *c, int width, int height) { c->type = CONTENT_HTML; return html_convert(c, width, height); } + +void directory_destroy(struct content *c) +{ + /* This will only get called if the content is destroyed before + * content_convert() is called. Simply force the type to HTML and + * delegate the cleanup to html_destroy() */ + + c->type = CONTENT_HTML; + + html_destroy(c); + + return; +} -- cgit v1.2.3