Moved buffer size check after the declarations block
Otherwise it is not a valid C code.