<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [GTK] Confusing webkit_uri_scheme_request_finish_error() description"
   href="https://bugs.webkit.org/show_bug.cgi?id=167495">167495</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[GTK] Confusing webkit_uri_scheme_request_finish_error() description
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>WebKit
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>WebKit Local Build
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Unspecified
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Unspecified
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>Normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P2
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>WebKit Gtk
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>webkit-unassigned&#64;lists.webkit.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>mcrha&#64;redhat.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>bugs-noreply&#64;webkitgtk.org, tpopela&#64;redhat.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I just found out in one of my valgrind logs this:

==8106== 52 (32 direct, 20 indirect) bytes in 2 blocks are definitely lost in loss record 22,849 of 44,246
==8106==    at 0x4C2DB9D: malloc (vg_replace_malloc.c:299)
==8106==    by 0x6AC229E: g_malloc (gmem.c:94)
==8106==    by 0x6ADC406: g_slice_alloc (gslice.c:1025)
==8106==    by 0x6AA2767: g_error_new_literal (gerror.c:471)
==8106==    by 0x969D47F: web_view_process_uri_request_cb (e-web-view.c:1103)
==8106==    by 0x751FB15: ??? (in /usr/lib64/libwebkit2gtk-4.0.so.37.14.9)
==8106==    by 0x753BB54: ??? (in /usr/lib64/libwebkit2gtk-4.0.so.37.14.9)
==8106==    by 0x753B7D4: ??? (in /usr/lib64/libwebkit2gtk-4.0.so.37.14.9)
==8106==    by 0x75B4B51: ??? (in /usr/lib64/libwebkit2gtk-4.0.so.37.14.9)
==8106==    by 0x75B4778: ??? (in /usr/lib64/libwebkit2gtk-4.0.so.37.14.9)
==8106==    by 0x72B4168: ??? (in /usr/lib64/libwebkit2gtk-4.0.so.37.14.9)
==8106==    by 0x73AB521: ??? (in /usr/lib64/libwebkit2gtk-4.0.so.37.14.9)
==8106==    by 0x72B02C5: ??? (in /usr/lib64/libwebkit2gtk-4.0.so.37.14.9)
==8106==    by 0x72B0F57: ??? (in /usr/lib64/libwebkit2gtk-4.0.so.37.14.9)
==8106==    by 0x1120EB9C: WTF::RunLoop::performWork() (in /usr/lib64/libjavascriptcoregtk-4.0.so.18.4.9)
==8106==    by 0x11235588: ??? (in /usr/lib64/libjavascriptcoregtk-4.0.so.18.4.9)
==8106==    by 0x6AB9C0B: g_main_dispatch (gmain.c:3203)
==8106==    by 0x6ABAABC: g_main_context_dispatch (gmain.c:3856)
==8106==    by 0x6ABACA1: g_main_context_iterate (gmain.c:3929)
==8106==    by 0x6ABB0C8: g_main_loop_run (gmain.c:4125)
==8106==    by 0x5D577E4: gtk_main (gtkmain.c:1301)
==8106==    by 0x404CB7: main (main.c:667)

This newly created GError instance is passed to the webkit_uri_scheme_request_finish_error(), which takes a non-const GError structure pointer and claims in the documentation:
/**
 * webkit_uri_scheme_request_finish_error:
 * &#64;request: a #WebKitURISchemeRequest
 * &#64;error: a #GError that will be passed to the #WebKitWebView
 *
 * Finish a #WebKitURISchemeRequest with a #GError.
 *
 * Since: 2.2
 */

that the GError will be passed somewhere. I'd understand from it that the function takes ownership of the &#64;error, the parameter type suggests the same (as being non-const), but when I checked the implementation the &#64;error is only dereferenced and its values are copied to some other structures, and even that not always.

I suggest to make the &#64;error a 'const GError *error' parameter of the function and eventually also write a note into the documentation that the 'error' is not taken by the function (which would be understood by the 'const' on its own).

Opinions?</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>