Skip to content
  • Georges Basile Stavracas Neto's avatar
    14909ffe
    gio/subprocess: Initialize pid variable to 0 · 14909ffe
    Georges Basile Stavracas Neto authored
    The documentation for g_spawn_async_with_pipes_and_fds() states:
    
    > If an error occurs, child_pid, stdin_pipe_out, stdout_pipe_out, and
    > stderr_pipe_out will not be filled with valid values.
    
    Before 2dc3a6f0, the `child_pid`
    argument was `self->pid`, and GObject zero-initializes structs. So
    the pid field was properly initialized to zero.
    
    After 2dc3a6f0, however, the out
    variable is now declared inside initable_init(), and it's unitialized.
    So if g_spawn_async_with_pipes_and_fds() errors out, `pid` will have
    trash value in it, and the following assertion will fail:
    
    ```
    g_assert (success == (pid != 0));
    ```
    
    Fix that by initializing the `pid` variable to zero. Add a test to
    exercise the fail code path, and prevent errors like this in the
    future.
    14909ffe
    gio/subprocess: Initialize pid variable to 0
    Georges Basile Stavracas Neto authored
    The documentation for g_spawn_async_with_pipes_and_fds() states:
    
    > If an error occurs, child_pid, stdin_pipe_out, stdout_pipe_out, and
    > stderr_pipe_out will not be filled with valid values.
    
    Before 2dc3a6f0, the `child_pid`
    argument was `self->pid`, and GObject zero-initializes structs. So
    the pid field was properly initialized to zero.
    
    After 2dc3a6f0, however, the out
    variable is now declared inside initable_init(), and it's unitialized.
    So if g_spawn_async_with_pipes_and_fds() errors out, `pid` will have
    trash value in it, and the following assertion will fail:
    
    ```
    g_assert (success == (pid != 0));
    ```
    
    Fix that by initializing the `pid` variable to zero. Add a test to
    exercise the fail code path, and prevent errors like this in the
    future.
Loading