[PATCH 1/4] libcamera: utils: Avoid infinite recursion with strtod()

Stefan Klug stefan.klug at ideasonboard.com
Fri May 3 16:37:55 CEST 2024


Hi Laurent,

thanks for the patch.

On Fri, May 03, 2024 at 05:52:02AM +0300, Laurent Pinchart wrote:
> When the C library doesn't provide local object support, the
> utils::strtod() function simply calls strtod() from the C library. The
> current implementation does so incorrectly, and calls utils::strtod()
> instead, resulting in infinite recursion. Fix it with a proper namespace
> qualifier.

Makes me curious which clib that was.
Reviewed-by: Stefan Klug <stefan.klug at ideasonboard.com> 

Cheers,
Stefan

> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> ---
>  src/libcamera/base/utils.cpp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/libcamera/base/utils.cpp b/src/libcamera/base/utils.cpp
> index 2f4c3177ac13..96023f992e03 100644
> --- a/src/libcamera/base/utils.cpp
> +++ b/src/libcamera/base/utils.cpp
> @@ -517,7 +517,7 @@ double strtod(const char *__restrict nptr, char **__restrict endptr)
>  	 * If the libc implementation doesn't provide locale object support,
>  	 * assume that strtod() is locale-independent.
>  	 */
> -	return strtod(nptr, endptr);
> +	return ::strtod(nptr, endptr);
>  #endif
>  }
>  
> -- 
> Regards,
> 
> Laurent Pinchart
> 


More information about the libcamera-devel mailing list