in reply to Uncontrolled Memory Allocation

This hopefully deciphers the error message Uncontrolled Memory Allocation https://stackoverflow.com/questions/64169882/how-to-solve-checkmarxs-issue-uncontrolled-memory-allocation Though Corion and haukex seem to have diagnosed it correctly. In plain words, you allow an external source (the size of the file and the size of each line of the file) to dictate to your program how much memory to allocate for reading it in, risking memory exhaustion. You need to keep Checkmarx happy and your supervisor happy. CheckKarlMarx would have said "a spectre is haunting you".

Also, it has been crosposted https://stackoverflow.com/questions/77089585/uncontrolled-memory-allocation-error-in-perl

Replies are listed 'Best First'.
Re^2: Uncontrolled Memory Allocation
by ikegami (Patriarch) on Sep 14, 2023 at 12:52 UTC

    My answer from there


    There are two ways in which the size of the hash is dependent on user data.

    • The length of the lines.
    • The number of unique lines.

    Your check accounts for one, but not the other.

    Mind you, <INFILE> alone "suffers" from "uncontrolled memory allocation". If you allow that, what's the point in limiting the size of the hash?