[Info-vax] calloc fails with access violation

JF Mezei jfmezei.spamnot at vaxination.ca
Mon Aug 24 22:46:30 EDT 2009


One way to test is to print, not the string, but the strlen(string)
before calling calloc.

So just before you program crashes, you would see the length of the
string that you are about to ask calloc to allocate.

If you find that it is only 80 bytes, then there is another problem
(harder to find). But if you find that it is 732737373 bytes, then you
know that your strlen() function yielded some very large number.

Again, a Cobol program will not null-terminate a string when passing it
to a CALL function. It will just pass the address to the first byte of
that string. (with the default call by reference). You may have been
lucky if you had data after the string that generally contained a null.

Also make sure that you don't feed some negative number to calloc.



More information about the Info-vax mailing list