On Thursday 02 October 2008 13:37:28 [EMAIL PROTECTED] wrote:
> Author: julianalbo
> Date: Thu Oct 2 13:37:27 2008
> New Revision: 31570
>
> Modified:
> trunk/src/ops/io.ops
>
> Log:
> some fixes in the open opcode
> --- trunk/src/ops/io.ops (original)
> +++ trunk/src/ops/io.ops Thu Oct 2 13:37:27 2008
> inline op open(out PMC, in STR) :filesys_open {
> /* These char * need to go away soon */
> - char * const path = string_to_cstring(interp, $2);
> -
> - $1 = PIO_open(interp, NULL, path, "+<");
> - string_cstring_free(path);
> - if (!$1)
> - $1 = pmc_new(interp, enum_class_Undef);
> + if (STRING_IS_NULL($2)) {
> + Parrot_ex_throw_from_c_args(interp, NULL,
> + EXCEPTION_UNEXPECTED_NULL, "Invalid open");
> + }
> + else {
> + char * const path = string_to_cstring(interp, $2);
> +
> + $1 = PIO_open(interp, NULL, path, "+<");
> +
> + string_cstring_free(path);
> + PARROT_ASSERT(! PMC_IS_NULL($1));
> + }
Can anything in the PIO_open() path throw an exception? If so, these strings
will leak. (This makes me wonder *why* PIO_open() takes C strings.)
-- c