Still working on memory bugs in neural_cluster.c

This commit is contained in:
BlackLight 2011-02-15 17:58:05 +01:00
parent b8f9c7fb8a
commit e2f5345c3b

View file

@ -111,27 +111,12 @@ __AI_neural_clusters_to_xml ( kmeans_t *km, AI_alerts_per_neuron *alerts_per_neu
* that there is no duplicate alert on other neurons */
if ( !are_equal )
{
for ( l=0; l <= i && !are_equal; l++ )
for ( l=0; l < km->k && !are_equal; l++ )
{
for ( m=0; m < j && !are_equal; m++ )
for ( m=0; m < km->cluster_sizes[l] && !are_equal; m++ )
{
/* Yeah, dirty horrible way for avoiding some SEGFAULTs for invalid memory access,
* but it's the only working way on some 64-bits architectures */
if ((unsigned long int) km->clusters < 0x100 )
if ( l <= i && m < j )
{
continue;
}
if ((unsigned long int) km->clusters[l] < 0x100 )
{
continue;
}
if ((unsigned long int) km->clusters[l][m] < 0x100 )
{
continue;
}
tmp_key.x = km->clusters[l][m][0];
tmp_key.y = km->clusters[l][m][1];
HASH_FIND ( hh, alerts_per_neuron, &tmp_key, sizeof ( tmp_key ), tmp_iterator );
@ -157,6 +142,7 @@ __AI_neural_clusters_to_xml ( kmeans_t *km, AI_alerts_per_neuron *alerts_per_neu
}
}
}
}
if ( !are_equal )
{