Re: [Vala] Possibly, error in code generator



Hi,

On Mon, 2007-12-10 at 18:22 +0300, Denis Cheremisov wrote:
The program gives segmentation fault. 

FileStream.open is a static method (fopen) that creates and returns a
new FileStream (FILE*).

"new FileStream ()" should be rejected by valac as there is no such
creation method in the FileStream class. It's a bug in valac that it
doesn't complain about this invalid code.

Try something like this:

FileStream file = FileStream.open (filename, "r");

There is another issue with the code: you may not call close() in this
situation as Vala calls close() automatically when the file variable
goes out of scope (or when you explicitly set it to null). I should fix
valac to disallow manual close calls in such cases.

These changes will hopefully prevent the segmentation faults.

Jürg




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]