msi: Initialize string pointer to NULL

View: New views
2 Messages — Rating Filter:   Alert me  

msi: Initialize string pointer to NULL

by Kirill K. Smirnov :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Nathan,
>+        haystack_table_name = NULL;
>         r = table->ops->get_column_info( table, i, &col_name, NULL,
>                                          NULL, &haystack_table_name );
>         if( r != ERROR_SUCCESS )

  I'm afraid, but this patch silences valgrind only, but does not solves the
problem. It seems to me, that if table->ops->get_column_info() succeeds, it
initializes haystack_table_name, and if it fails, we do not use
haystack_table_name at all (we immediately return from this function). Thus,
the problem lies somewhere in get_column_info().

So it is useless (and harmful, because it confuses valgrind) to initialize it
like this.

--
Kirill



Re: msi: Initialize string pointer to NULL

by Nate Gallaher :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Kirill,

I see what you're getting at. The valgrind error comes about when we call
get_column_info in streams.c. No string is allocated for table_name there,
so the pointer remains uninitialized.

I am unfamiliar with the streams use case, but looking at
tests/db.c:test_streamtable(), I think that the correct tablename to be
returning is '_Streams'.  Would you agree?

Thanks,
~Nathan

  On Sun, 1 Nov 2009, Kirill K. Smirnov wrote:

> Hi Nathan,
>> +        haystack_table_name = NULL;
>>         r = table->ops->get_column_info( table, i, &col_name, NULL,
>>                                          NULL, &haystack_table_name );
>>         if( r != ERROR_SUCCESS )
>
>  I'm afraid, but this patch silences valgrind only, but does not solves the
> problem. It seems to me, that if table->ops->get_column_info() succeeds, it
> initializes haystack_table_name, and if it fails, we do not use
> haystack_table_name at all (we immediately return from this function). Thus,
> the problem lies somewhere in get_column_info().
>
> So it is useless (and harmful, because it confuses valgrind) to initialize it
> like this.
>
> --
> Kirill
>