1. It's certainly not the best policy. I'm a little unclear how this should be changed, I'll probably shift is around so the test is solely before the parent->type is set. if ( ! stack->data ) continue;
I'm guessing the only way to trigger the current fault would be to craft a specific invalid .vik file of Layers within wrong Layers. This of course would be useful in proving that the fix is right. 2. Yes. This can be clearly improved. I think simply gl can be reset is just gl = g_list_first ( gl ); Rather than as you say calculating the full list again. Thanks for spotting these. -- Be Seeing You - Rob. If at first you don't succeed, then skydiving isn't for you. ________________________________________ From: Kamil Ignacak <kamil.igna...@gmail.com> Sent: 07 July 2018 13:10:37 To: viking-devel Subject: [Viking-devel] Two questions: file.c and vikaggregatelayer.c Hello, During my work with code I have found two places in the code that I would like to ask about - can you please take a look? The code is from repo's head: 1. file.c:324 int parent_type = VIK_LAYER(stack->data)->type; if ( ( ! stack->data ) || ((parent_type != VIK_LAYER_AGGREGATE) && (parent_type != VIK_LAYER_GPS)) ) In second line we test if stack->data is NULL, but in first line we dereference the stack->data pointer, which may be NULL. I'm no expert on gobjects, but I suspect that this dereferencing of potentially NULL pointer (before testing it) may be risky. 2. vikaggregatelayer.c/aggregate_layer_search_date():557 if ( !found ) { // Reset and try on Waypoints gl = NULL; gl = vik_aggregate_layer_get_all_layers_of_type ( val, gl, VIK_LAYER_TRW, TRUE ); Is the "reset" of gl and a second execution of vik_aggregate_layer_get_all_layers_of_type() (which may be time consuming) necessary? Would it be possible to save some time and re-use gl (or previously stored copy of gl)? Best regards, Kamil ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Viking-devel mailing list Viking-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/viking-devel Viking home page: http://viking.sf.net/