Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SIO_INPUT stream allows write #1233

Open
kamahen opened this issue Feb 7, 2024 · 1 comment
Open

SIO_INPUT stream allows write #1233

kamahen opened this issue Feb 7, 2024 · 1 comment

Comments

@kamahen
Copy link
Member

kamahen commented Feb 7, 2024

The following code didn't produce an exception. I need to do some additional work to make sure it isn't a bug in my test cases - the test case creates the stream term using with_output_to(string(String), ...), so the problem could be there. [Opening an "issue" because I don't want to forget this - please assign it to me if the problem isn't obvious]

static foreign_t
w_atom_ffi_(term_t stream, term_t t)
{ IOSTREAM* s;
  atom_t a;
  if ( !PL_get_stream(stream, &s, SIO_INPUT || /* should be SIO_OUTPUT */
       !PL_get_atom_ex(t, &a) )
    return FALSE;
  PL_STRINGS_MARK();
    size_t len;
    const pl_wchar_t *sa = PL_atom_wchars(a, &len);
    SfprintfX(s, "/%Ws/%zd", sa, len); /* should fail */
  PL_STRINGS_RELEASE();
  return TRUE;
}

For the test, this is wrapped with:

w_atom_ffi(Atom, String) :-
    with_output_to(string(String), w_atom_ffi_(current_output, Atom)).
@JanWielemaker
Copy link
Member

I think it should indeed produce an exception. Run under gdb, break on PL_raise_exception() and see how it goes on ....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants