@@ -283,11 +283,11 @@ void readbinary_statement(struct basic_ctx* ctx)
283283 int64_t buffer = expr (ctx );
284284 accept_or_return (COMMA , ctx );
285285 int64_t size = expr (ctx );
286- if (!address_valid_write (buffer , size )) {
286+ if (size && !address_valid_write (buffer , size )) {
287287 tokenizer_error_printf (ctx , "Invalid address: %016lx" , (uint64_t )buffer );
288288 return ;
289289 }
290- if (_read (fd , buffer , size ) == -1 ) {
290+ if (size && _read (fd , buffer , size ) == -1 ) {
291291 tokenizer_error_printf (ctx , "Error reading from file: %s" , fs_strerror (fs_get_error ()));
292292 }
293293 accept_or_return (NEWLINE , ctx );
@@ -301,11 +301,11 @@ void writebinary_statement(struct basic_ctx* ctx)
301301 int64_t buffer = expr (ctx );
302302 accept_or_return (COMMA , ctx );
303303 int64_t size = expr (ctx );
304- if (!address_valid_read (buffer , size )) {
304+ if (size && !address_valid_read (buffer , size )) {
305305 tokenizer_error_printf (ctx , "Invalid address: %016lx" , (uint64_t )buffer );
306306 return ;
307307 }
308- if (_write (fd , buffer , size ) == -1 ) {
308+ if (size && _write (fd , buffer , size ) == -1 ) {
309309 tokenizer_error_printf (ctx , "Error writing to file: %s" , fs_strerror (fs_get_error ()));
310310 }
311311 accept_or_return (NEWLINE , ctx );
0 commit comments