From f7bbca99e7b811668b3e75d2d22788bd32c0b261 Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" Date: Tue, 8 Dec 2020 11:26:22 +0000 Subject: [PATCH] WebView: fixed critical memory leak git-svn-id: svn://kolibrios.org@8339 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/cmm/browser/TWB/TWB.c | 2 +- programs/cmm/browser/TWB/img.h | 46 +++++++++++----------------------- programs/cmm/browser/WebView.c | 2 +- programs/cmm/browser/cache.h | 2 ++ programs/cmm/downloader/dl.c | 2 -- programs/cmm/misc/osupdate.c | 2 +- 6 files changed, 20 insertions(+), 36 deletions(-) diff --git a/programs/cmm/browser/TWB/TWB.c b/programs/cmm/browser/TWB/TWB.c index 68f4eb5a15..7a31e0ccb4 100644 --- a/programs/cmm/browser/TWB/TWB.c +++ b/programs/cmm/browser/TWB/TWB.c @@ -464,7 +464,7 @@ void TWebBrowser::SetStyle() { EDI = EAX; img.w.add(ESDWORD[EDI+4]); img.h.add(ESDWORD[EDI+8]); - free(EDI); + img_destroy stdcall(EDI); img.url.add(#img_path); diff --git a/programs/cmm/browser/TWB/img.h b/programs/cmm/browser/TWB/img.h index 0c3c136ef2..36acf0da1c 100644 --- a/programs/cmm/browser/TWB/img.h +++ b/programs/cmm/browser/TWB/img.h @@ -29,40 +29,24 @@ void _img::add(dword _path, _x, _y, _w, _h) h.add(_h); } -/* -void _img::draw_all(int _x, _y, _w, _h, _start) -{ - int i, img_y; - - for (i=0; i _start) && (img_y - _h < _start) - && (cache.has(url.get(i))) draw(_x, _y, _w, _h, _start, i); - } -} -*/ - bool _img::draw(int _x, _y, _w, _h, _start, i) { int img_x, img_y, img_w, img_h, invisible_h=0; + char* img_ptr; + + img_x = x.get(i); + img_y = y.get(i); + img_w = math.min(w.get(i), _w - img_x); + img_h = math.min(h.get(i), _h + _start - img_y); + + if (_start > img_y) { + invisible_h = _start - img_y; + img_y = _start; + } + img_decode stdcall (cache.current_buf, cache.current_size, 0); - if (EAX) { - EDI = EAX; - - img_x = x.get(i); - img_y = y.get(i); - img_w = math.min(w.set(i, ESDWORD[EDI+4]), _w - img_x); - img_h = math.min(h.set(i, ESDWORD[EDI+8]), _h + _start - img_y); - - if (_start > img_y) { - invisible_h = _start - img_y; - img_y = _start; - } - - img_draw stdcall(EDI, img_x + _x, img_y - _start + _y, img_w, img_h - invisible_h, 0, invisible_h); - free(EDI); - } + img_ptr = EAX; + img_draw stdcall(img_ptr, img_x + _x, img_y - _start + _y, img_w, img_h - invisible_h, 0, invisible_h); + img_destroy stdcall(img_ptr); } diff --git a/programs/cmm/browser/WebView.c b/programs/cmm/browser/WebView.c index 736ec756bb..3a30fcae84 100644 --- a/programs/cmm/browser/WebView.c +++ b/programs/cmm/browser/WebView.c @@ -42,7 +42,7 @@ // DATA // // // //===================================================// -char version[]="WebView 2.8 BETA"; +char version[]="WebView 2.8 BETA 2"; #define DEFAULT_URL URL_SERVICE_HOMEPAGE diff --git a/programs/cmm/browser/cache.h b/programs/cmm/browser/cache.h index 5dc269877d..984f6d3f1f 100644 --- a/programs/cmm/browser/cache.h +++ b/programs/cmm/browser/cache.h @@ -43,6 +43,8 @@ bool _cache::has(dword _link) void _cache::clear() { + int i; + for (i=0; i