[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: feature/tree-sitter 3069849bd4 4/4: * src/treesit.c (treesit_load_la
From: |
Po Lu |
Subject: |
Re: feature/tree-sitter 3069849bd4 4/4: * src/treesit.c (treesit_load_language): Fix uninitialized uses. |
Date: |
Mon, 21 Nov 2022 19:59:28 +0800 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
Yuan Fu <casouri@gmail.com> writes:
> branch: feature/tree-sitter
> commit 3069849bd4c1048a8f8c0467d26560fad939e791
> Author: Po Lu <luangruo@yahoo.com>
> Commit: Po Lu <luangruo@yahoo.com>
>
> * src/treesit.c (treesit_load_language): Fix uninitialized uses.
> ---
> src/treesit.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/src/treesit.c b/src/treesit.c
> index 291698e4e4..599a9b883e 100644
> --- a/src/treesit.c
> +++ b/src/treesit.c
> @@ -554,9 +554,11 @@ treesit_load_language (Lisp_Object language_symbol,
> when succeed, record the error message and try the next one when
> fail. */
> dynlib_handle_ptr handle;
> - char const *error;
> + const char *error;
>
> tail = path_candidates;
> + error = NULL;
> + handle = NULL;
>
> FOR_EACH_TAIL (tail)
> {
> @@ -568,6 +570,9 @@ treesit_load_language (Lisp_Object language_symbol,
> break;
> }
>
> + /* ??? */
> + eassume (handle != NULL);
> +
> if (error != NULL)
> {
> *signal_symbol = Qtreesit_load_language_error;
>
> Thanks for working on this. What does ??? mean? Why do we assume
> handle is not NULL?
handle can only be set if tail is non-nil, but I do not think that is
always the case.
The code below seemed to call dynlib_sym (handle, c_name) without any
checks. I was going to ask about it, but I forgot.