From baa0dc8c594b7cfe007cfb129bce81104c3b8895 Mon Sep 17 00:00:00 2001 From: onefang Date: Tue, 21 Apr 2020 02:35:22 +1000 Subject: Fix some leaks. --- src/sledjchisl/sledjchisl.c | 43 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/src/sledjchisl/sledjchisl.c b/src/sledjchisl/sledjchisl.c index 05704e9..b05aaa0 100644 --- a/src/sledjchisl/sledjchisl.c +++ b/src/sledjchisl/sledjchisl.c @@ -2637,7 +2637,8 @@ void unfragize(qlist_t *fragments, reqData *Rd, boolean fre) E("NULL fragment!"); continue; } - HTMLfill(Rd, frg->type, frg->text, frg->length); + if (NULL != Rd) + HTMLfill(Rd, frg->type, frg->text, frg->length); if (fre) free(frg->text); } @@ -4305,23 +4306,29 @@ static void accountLoginWeb(reqData *Rd, inputForm *oF, inputValue *oV) static void accountViewWeb(reqData *Rd, inputForm *oF, inputValue *oV) { + char *name = getStrH(Rd->stuff, "name"), + *email = displayPrep(getStrH(Rd->stuff, "email")), + *voucher = displayPrep(getStrH(Rd->database, "Lua.voucher")), + *about = displayPrep(getStrH(Rd->database, "Lua.aboutMe")); time_t crtd = atol(getStrH(Rd->database, "UserAccounts.Created")); - accountWebHeaders(Rd, oF, getStrH(Rd->stuff, "name")); + accountWebHeaders(Rd, oF, name); accountWebFields(Rd, oF, oV); // TODO - still need to encode < > as < u> for email, voucher, and about. // TODO - dammit, qurl_decode returns the string length, and decodes the string in place. Rd->reply->addstrf(Rd->reply, "

Title / level : %s / %d

", getLevel(Rd), Rd->shs.level); Rd->reply->addstrf(Rd->reply, "

Date of birth : %s

", getStrH(Rd->database, "Lua.DoB")); Rd->reply->addstrf(Rd->reply, "

Created : %s

", ctime(&crtd)); - Rd->reply->addstrf(Rd->reply, "

Email : %s

", displayPrep(getStrH(Rd->stuff, "email"))); + Rd->reply->addstrf(Rd->reply, "

Email : %s

", email); Rd->reply->addstrf(Rd->reply, "

UUID : %s

", Rd->shs.UUID); - Rd->reply->addstrf(Rd->reply, "

Voucher : %s

", displayPrep(getStrH(Rd->database, "Lua.voucher"))); + Rd->reply->addstrf(Rd->reply, "

Voucher : %s

", voucher); // Rd->reply->addstrf(Rd->reply, "

About :

" // "", qurl_decode(getStrH(Rd->database, "Lua.aboutMe"))); - HTMLtextArea(Rd->reply, "aboutMe", "About", 7, 50, 4, 16384, "", "off", "true", "soft", displayPrep(getStrH(Rd->database, "Lua.aboutMe")), FALSE, TRUE); + HTMLtextArea(Rd->reply, "aboutMe", "About", 7, 50, 4, 16384, "", "off", "true", "soft", about, FALSE, TRUE); accountWebSubs(Rd, oF); accountWebFooter(Rd, oF); + free(about); free(voucher); free(email); + } static void accountEditWeb(reqData *Rd, inputForm *oF, inputValue *oV) @@ -5324,7 +5331,11 @@ static void cleanup(void) accountPages->lock(accountPages); while(accountPages->getnext(accountPages, &obj, true) == true) { -// d("%s = %s", obj.name, (char *) obj.data); + inputForm *f = (inputForm *) obj.data; + +//d("%s = %s", obj.name, (char *) obj.data); + f->subs->free(f->subs); + f->fields->free(f->fields); } accountPages->unlock(accountPages); accountPages->free(accountPages); @@ -5333,8 +5344,22 @@ static void cleanup(void) // if (fieldValidFuncs) fieldValidFuncs->free(fieldValidFuncs); // if (buildPages) buildPages->free(buildPages); if (dynPages) dynPages->free(dynPages); - if (HTMLfileCache) HTMLfileCache->free(HTMLfileCache); - if (HTMLfileCache) mimeTypes->free(mimeTypes); + if (HTMLfileCache) + { + qhashtbl_obj_t obj; + + memset((void*)&obj, 0, sizeof(obj)); + HTMLfileCache->lock(HTMLfileCache); + while(HTMLfileCache->getnext(HTMLfileCache, &obj, true) == true) + { + HTMLfile *f = (HTMLfile *) obj.data; + + unfragize(f->fragments, NULL, TRUE); + } + HTMLfileCache->unlock(HTMLfileCache); + HTMLfileCache->free(HTMLfileCache); + } + if (mimeTypes) mimeTypes->free(mimeTypes); if (dbRequests) dbRequests->free(dbRequests); if (database) mysql_close(database); mysql_library_end(); @@ -5942,7 +5967,7 @@ goto sendReply; goto sendReply; getStats(database, stats); - unfragize(thisFile->fragments, Rd, false); + unfragize(thisFile->fragments, Rd, FALSE); free(thisFile); sendReply: -- cgit v1.1