goeran@ae.chalmers.se (01/25/90)
I found an problem with get_post_defaults in NEWSPOST.C (V5.9C). The malloc calls in the following lines should allocate more memory for locdst and locfol. If not, memory corruption can occur when locdst and locfol are given values (or extended) by entries from NEWS_POST.DEFAULTS and/or default values (defdist and deffol) later in get_post_defaults (in fact, in the add_keys routine). This will of course only occur if you use the NEWS_POST.DEFAULTS file. --- locgrp = malloc(strlen(groups) + 3); locdst = malloc(strlen(cur_dist) + 3); locfol = malloc(strlen(cur_follow) + 3); --- Like other memory corruptions, it can cause very obscure problems. I disabled the use of the VAXC$*_OPT routines to have better control over memory allocation (to track down the problem) and in my case the internal structure used by malloc to keep track of allocated memory (a one block cache in front of LIB$GET_VM) was modified, causing malloc to return the same address twice in successive calls (and fail, i.e. return 0, later)... Both resulting in an access violation several lines later. (The symptom is not exactly the same when using the VAXC$*_OPT routines). The quick and dirty fix was to change them to: --- locdst = malloc(strlen(cur_dist) + 3 + 512); locfol = malloc(strlen(cur_follow) + 3 + 512); --- and that solved my problem. A more elegant fix may be to use other variables and/or reallocate them when the actual size is known. Regards, G|ran Bengtson Chalmers Univ. of Technology goeran@ae.chalmers.se