RESOLVED FIXED190865
[WPE][GTK] Cleanups to the certificate encoder
https://bugs.webkit.org/show_bug.cgi?id=190865
Summary [WPE][GTK] Cleanups to the certificate encoder
Claudio Saavedra
Reported 2018-10-24 01:01:29 PDT
[WPE][GTK] Remove redundant variable from certificate encoder
Attachments
Patch (2.21 KB, patch)
2018-10-24 01:01 PDT, Claudio Saavedra
no flags
Patch (2.32 KB, patch)
2018-10-24 01:51 PDT, Claudio Saavedra
zan: review+
mcatanzaro: commit-queue-
Claudio Saavedra
Comment 1 2018-10-24 01:01:46 PDT
Zan Dobersek
Comment 2 2018-10-24 01:26:05 PDT
Comment on attachment 353027 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=353027&action=review > Source/WebKit/Shared/soup/WebCoreArgumentCodersSoup.cpp:61 > GByteArray* certificateData = 0; > Vector<GByteArray*> certificatesDataList; Move `certificateData` into the `do { }` scope, limiting its use to that part of the code. `certificatesDataList` should IMO be a Vector<GRefPtr<GByteArray>>, immediately adopting the `certificateData` pointer and avoiding the out-of-the-blue adoptGRef() int the loop below. > Source/WebKit/Shared/soup/WebCoreArgumentCodersSoup.cpp:80 > + for (int i = certificatesDataList.size(); i > 0; i--) { Use size_t for `i`. In the post-loop segment, use the prefixed decrement: `--i`.
Claudio Saavedra
Comment 3 2018-10-24 01:51:40 PDT
Zan Dobersek
Comment 4 2018-10-24 01:56:15 PDT
Comment on attachment 353028 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=353028&action=review > Source/WebKit/Shared/soup/WebCoreArgumentCodersSoup.cpp:63 > + GByteArray* certificateData = 0; > g_object_get(G_OBJECT(certificate), "certificate", &certificateData, NULL); `nullptr` should be used in both lines. > Source/WebKit/Shared/soup/WebCoreArgumentCodersSoup.cpp:80 > + GRefPtr<GByteArray> certificate = certificatesDataList[i - 1]; This takes an extra reference to the GByteArray pointer stored in the Vector. Use auto& to bind a C++ reference to the existing GRefPtr instead: `auto& certificate = ...`
Claudio Saavedra
Comment 5 2018-10-24 02:10:42 PDT
Radar WebKit Bug Importer
Comment 6 2018-10-24 02:11:27 PDT
Michael Catanzaro
Comment 7 2018-10-24 07:06:08 PDT
Comment on attachment 353028 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=353028&action=review > Source/WebKit/Shared/soup/WebCoreArgumentCodersSoup.cpp:68 > certificatesDataList.append(certificateData); I think you need adoptGRef() here to avoid leaking it, right? >> Source/WebKit/Shared/soup/WebCoreArgumentCodersSoup.cpp:80 >> + GRefPtr<GByteArray> certificate = certificatesDataList[i - 1]; > > This takes an extra reference to the GByteArray pointer stored in the Vector. Use auto& to bind a C++ reference to the existing GRefPtr instead: > `auto& certificate = ...` It's less confusing if you bypass the GRefPtr (because you don't need to hold a ref here) and just go straight to the GByteArray: GByteArray* certificate = certificatesDataList[i - 1].get();
Michael Catanzaro
Comment 8 2018-10-24 07:09:56 PDT
Oh I missed that you already committed (cq? was still set, try not to forget about that). Anyway, my second comment isn't important, but please check the first one to make sure you're not leaking.
Note You need to log in before you can comment on or make changes to this bug.