Correct segmentation fault when asking for an invalid layer_index in layer_name function