Summary

bug in specialized-io egg

Metadata

Description

The foreign code should probably be declared to return `int`:

 (define write-one-char
   (lambda (c port)
     (if (fx= 1 ((foreign-lambda* void ((char var)
                                        (scheme-object port))
                                  "#include <stdio.h> \n"
                                  "if (fputc (var, C_port_file(port)) == EOF)"
                                  "     return(1);"
                                  "else"
                                  "     return(0);")
                 c port))
         (specialized-io-error "write-one-char: failed!"))))

Changes and comments

[2011-08-31 20:58:35 UTC] mario changed status from new to assigned

[2011-08-31 20:58:35 UTC] mario set owner to jeronimo

[2011-09-04 22:21:19 UTC] jeronimo changed status from assigned to closed

[2011-09-04 22:21:19 UTC] jeronimo set resolution to worksforme

[2011-09-04 22:21:19 UTC] jeronimo wrote:

Hi,

Indeed, the void declaration made no sense! It's fixed in trunk and in version 1.2.

However, specialized-io is unsafe in order to be fast, and trying to write to something that is not a port will crash the program.

The verification done is for the case when one tries to write to a closed port or to an input port.