← Back to team overview

maria-developers team mailing list archive

Re: [Commits] 44f3058: Prevent undefined behavior if the table is already initialized

 

Hi, Vicențiu!

On Sep 20, Vicențiu Ciorbaru wrote:
> Hi Sergey, Monty!
> 
> CCed Monty as he last touched this code as part of MDEV-8408.
> 
> This patch comes after I found a warning during compilation that says that
> we might be using the error variable as uninitialised.
> Looking at the code:
>   int error;
>   /* ..... */
>   if (!table->file->inited &&
>       (error= table->file->ha_index_init(idx, 1)))
>   /* ... */
>   DBUG_RETURN(error != 0);
> 
> Here, if table->file->inited is actually set to true, the error
> variable is never set. The problem is that i'm not sure if we should
> be returning a failure or not. I considered that having the table
> initialised _before_ this call would lead to "not-an-error". Then
> again, the semantics are strange and I couldn't figure out exactly
> which is the correct return value.
> 
> Thoughts?

Can table->file->inited be true here at all?

I've added an assertion there and run the main test suite (in normal and
--ps-protocol, just in case) - it has never fired.

So, I'd speculate that table->file->inited must be always false there and
that assert looks more appropriate than if() there.

Regards,
Sergei
Chief Architect MariaDB
and security@xxxxxxxxxxx