None of the possible values that should be passed to io.read() should be taken from user input, especially not directly, so I fail to see how this is any different than calling malloc() with a user value. The issue isn't that malloc() allocates as much memory
as you ask for, it's that you let someone else decide how much to ask for.