Fixed a bug where an unmapped variable would be read

This commit is contained in:
Celine Mercier
2016-06-03 18:55:58 +02:00
parent 2962c4d250
commit 2f57f80c63

View File

@ -350,10 +350,11 @@ OBIDMS_column_p clone_column_in_view(Obiview_p view, const char* column_name)
obi_close_column(column_buffer); obi_close_column(column_buffer);
if (!(strcmp((((view->columns)[i])->header)->name, column_name))) if (!(strcmp((((view->columns)[i])->header)->name, column_name)))
// Found the column to return { // Found the column to return
column = (view->columns)[i]; column = (view->columns)[i];
} }
} }
}
// Close old line selections // Close old line selections
if (view->line_selection != NULL) if (view->line_selection != NULL)
@ -373,6 +374,8 @@ OBIDMS_column_p clone_column_in_view(Obiview_p view, const char* column_name)
int prepare_to_set_value_in_column(Obiview_p view, OBIDMS_column_p* column_pp, index_t* line_nb_p) int prepare_to_set_value_in_column(Obiview_p view, OBIDMS_column_p* column_pp, index_t* line_nb_p)
{ {
char* column_name;
// Check that the view is not read-only // Check that the view is not read-only
if (view->read_only) if (view->read_only)
{ {
@ -389,12 +392,22 @@ int prepare_to_set_value_in_column(Obiview_p view, OBIDMS_column_p* column_pp, i
if (view->line_selection != NULL) if (view->line_selection != NULL)
(*line_nb_p) = *(((index_t*) ((view->line_selection)->data)) + (*line_nb_p)); (*line_nb_p) = *(((index_t*) ((view->line_selection)->data)) + (*line_nb_p));
(*column_pp) = clone_column_in_view(view, ((*column_pp)->header)->name); column_name = (char*) malloc(strlen(((*column_pp)->header)->name) * sizeof(char));
if (column_name == NULL)
{
obi_set_errno(OBI_MALLOC_ERROR);
obidebug(1, "\nError trying to allocate memory for a column name");
return -1;
}
strcpy(column_name, ((*column_pp)->header)->name);
(*column_pp) = clone_column_in_view(view, column_name);
if ((*column_pp) == NULL) if ((*column_pp) == NULL)
{ {
obidebug(1, "\nError trying to clone a column to modify it"); obidebug(1, "\nError trying to clone a column to modify it");
return -1; return -1;
} }
free(column_name);
} }
if (((*line_nb_p)+1) > view->line_count) if (((*line_nb_p)+1) > view->line_count)