[libcamera-devel] libcamera: proxy: linux: Initialise pointer members at construction time

Message ID 20190915111820.11762-1-laurent.pinchart@ideasonboard.com
State Accepted
Headers show
Series
  • [libcamera-devel] libcamera: proxy: linux: Initialise pointer members at construction time
Related show

Commit Message

Laurent Pinchart Sept. 15, 2019, 11:18 a.m. UTC
If the IPAProxyLinux constructor fails to locate the proxy worker, the
socket_ and proc_ member pointers will be left uninitialised, leading
the a crash in the destructor. Initialise them both to nullptr.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/libcamera/proxy/ipa_proxy_linux.cpp | 1 +
 1 file changed, 1 insertion(+)

Comments

Jacopo Mondi Sept. 15, 2019, 12:38 p.m. UTC | #1
Hi Laurent,

On Sun, Sep 15, 2019 at 02:18:20PM +0300, Laurent Pinchart wrote:
> If the IPAProxyLinux constructor fails to locate the proxy worker, the
> socket_ and proc_ member pointers will be left uninitialised, leading
> the a crash in the destructor. Initialise them both to nullptr.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>

Thanks
   j
> ---
>  src/libcamera/proxy/ipa_proxy_linux.cpp | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/src/libcamera/proxy/ipa_proxy_linux.cpp b/src/libcamera/proxy/ipa_proxy_linux.cpp
> index 2a3872fdd52a..553714886f62 100644
> --- a/src/libcamera/proxy/ipa_proxy_linux.cpp
> +++ b/src/libcamera/proxy/ipa_proxy_linux.cpp
> @@ -38,6 +38,7 @@ private:
>  };
>
>  IPAProxyLinux::IPAProxyLinux(IPAModule *ipam)
> +	: proc_(nullptr), socket_(nullptr)
>  {
>  	LOG(IPAProxy, Debug)
>  		<< "initializing dummy proxy: loading IPA from "
> --
> Regards,
>
> Laurent Pinchart
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

Patch

diff --git a/src/libcamera/proxy/ipa_proxy_linux.cpp b/src/libcamera/proxy/ipa_proxy_linux.cpp
index 2a3872fdd52a..553714886f62 100644
--- a/src/libcamera/proxy/ipa_proxy_linux.cpp
+++ b/src/libcamera/proxy/ipa_proxy_linux.cpp
@@ -38,6 +38,7 @@  private:
 };
 
 IPAProxyLinux::IPAProxyLinux(IPAModule *ipam)
+	: proc_(nullptr), socket_(nullptr)
 {
 	LOG(IPAProxy, Debug)
 		<< "initializing dummy proxy: loading IPA from "