Skip to content

[Ruby] Potential compaction issue in rb_trilogy_connect? #140

Description

@casperisfine

While working on #139 I noticed something suspicious.

We have a number of statements like this:

    if ((val = rb_hash_lookup(opts, ID2SYM(id_host))) != Qnil) {
        Check_Type(val, T_STRING);

        connopt.hostname = StringValueCStr(val);

opts is held as @connection_options on the Trilogy instance, so val and it's char * won't be GCed, however:

  • We don't ensure the string is frozen, so it could be mutated later on.
  • We these strings aren't pined, so if they are embedded, they could be moved elsewhere, causing connopt to point at garbage / another object.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions