File fix_alist_null-deref.patch of Package ftnchek
Make sure that for every if-case an ArgListHeader object will be created by
calling make_arrayless_alist for the "is_interface && !interface_block" case.
This fixes an null pointer dereference caused by the previous "maybe-uninitialized.patch",
concretely due to the initialization of "a" in prlists.c:182.
This fix also cures some strange endless looping in a while loop at argcheck.c:832
At the same time fix indentation, as it was very misleading.
diff -Nupr ../ftnchek/prlists.c ftnchek/prlists.c
--- ../ftnchek/prlists.c 2020-09-10 10:41:54.405795825 +0200
+++ ftnchek/prlists.c 2020-10-29 17:05:00.479537757 +0100
@@ -189,21 +189,24 @@ else {
a,gsymt->info.arglist);
}
else if (head_ptr->is_interface) {
- /* For interface, create the dummy array
- * while in the interface block because
- * the dummies will be lost when the scope
- * gets popped off ( when interface block
- * is closed )
- */
- if (interface_block) {
- a=make_dummy_arg_array(head_ptr->tokenlist);
- make_arg_names(head_ptr->tokenlist,
- a,gsymt->info.arglist);
- }
- /* Interface is not a definition so set
- * to false.
- */
- loc_symtab[i].entry_point = FALSE;
+ /* For interface, create the dummy array
+ * while in the interface block because
+ * the dummies will be lost when the scope
+ * gets popped off ( when interface block
+ * is closed )
+ */
+ if (interface_block) {
+ a=make_dummy_arg_array(head_ptr->tokenlist);
+ make_arg_names(head_ptr->tokenlist,
+ a,gsymt->info.arglist);
+ } else {
+ /* Interface but no interface_block? Weird. We create a empty alist for now. Is this correct? */
+ a=make_arrayless_alist();
+ }
+ /* Interface is not a definition so set
+ * to false.
+ */
+ loc_symtab[i].entry_point = FALSE;
}
/* Subprogram invoked in an internal subprogram
* may also have invocations in the containing