Pain: we fail to distinguish between error (here) and "I correctly give you back an empty list because that's what you asked for" (above, string == NULL; and what ends up happening if max is 0 or, for some other reason, you never actually append anything).