Taxonomy: fixed a critical memory bug when building the list of merged
taxids
This commit is contained in:
@ -2376,9 +2376,10 @@ int read_merged_dmp(const char* taxdump, OBIDMS_taxonomy_p tax, int32_t* delnode
|
|||||||
// and the deleted taxids with no current reference. An element of the list is composed of the taxid, and the index
|
// and the deleted taxids with no current reference. An element of the list is composed of the taxid, and the index
|
||||||
// of the taxon in the taxa structure, or -1 for deleted taxids.
|
// of the taxon in the taxa structure, or -1 for deleted taxids.
|
||||||
// Creating the merged list requires to merge the 3 ordered lists into one.
|
// Creating the merged list requires to merge the 3 ordered lists into one.
|
||||||
while (((nT < (tax->taxa)->count) && ((tax->taxa)->taxon[nT].taxid < old_taxid)) || ((nD >= 0) && (delnodes[nD] < old_taxid)))
|
while (((nT < (tax->taxa)->count) && ((tax->taxa)->taxon[nT].taxid < old_taxid)) ||
|
||||||
|
((nD >= 0) && (delnodes[nD] < old_taxid)))
|
||||||
{
|
{
|
||||||
if ((tax->taxa)->taxon[nT].taxid < delnodes[nD])
|
if ((nT < (tax->taxa)->count) && (tax->taxa)->taxon[nT].taxid < delnodes[nD])
|
||||||
{ // Add element from taxa list
|
{ // Add element from taxa list
|
||||||
// Enlarge structure if needed
|
// Enlarge structure if needed
|
||||||
if (n == buffer_size)
|
if (n == buffer_size)
|
||||||
@ -2401,7 +2402,7 @@ int read_merged_dmp(const char* taxdump, OBIDMS_taxonomy_p tax, int32_t* delnode
|
|||||||
nT++;
|
nT++;
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
else if (delnodes[nD] < (tax->taxa)->taxon[nT].taxid)
|
else
|
||||||
{ // Add element from deleted taxids list
|
{ // Add element from deleted taxids list
|
||||||
// Enlarge structure if needed
|
// Enlarge structure if needed
|
||||||
if (n == buffer_size)
|
if (n == buffer_size)
|
||||||
@ -3036,12 +3037,12 @@ OBIDMS_taxonomy_p obi_read_taxonomy(OBIDMS_p dms, const char* taxonomy_name, boo
|
|||||||
|
|
||||||
strcpy(tax->tax_name, taxonomy_name);
|
strcpy(tax->tax_name, taxonomy_name);
|
||||||
|
|
||||||
buffer_size = 2048;
|
|
||||||
|
|
||||||
taxonomy_path = get_taxonomy_path(dms, taxonomy_name);
|
taxonomy_path = get_taxonomy_path(dms, taxonomy_name);
|
||||||
if (taxonomy_path == NULL)
|
if (taxonomy_path == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
buffer_size = strlen(taxonomy_path) + strlen(taxonomy_name) + 6;
|
||||||
|
|
||||||
// Read ranks
|
// Read ranks
|
||||||
ranks_file_name = (char*) malloc(buffer_size*sizeof(char));
|
ranks_file_name = (char*) malloc(buffer_size*sizeof(char));
|
||||||
if (ranks_file_name == NULL)
|
if (ranks_file_name == NULL)
|
||||||
|
Reference in New Issue
Block a user