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

Fix some errors #183

Merged
merged 9 commits into from Dec 18, 2017
Merged

Fix some errors #183

merged 9 commits into from Dec 18, 2017

Commits on Dec 12, 2017

  1. ✂️ whitespace errors

    tenderlove committed Dec 12, 2017
    Copy the full SHA
    5bfd12f View commit details
    Browse the repository at this point in the history
  2. freeze string keys

    tenderlove committed Dec 12, 2017
    Copy the full SHA
    c4c1749 View commit details
    Browse the repository at this point in the history
  3. Fix leak when non-object or array is passed to parser

    If something besides an object or array is passed to the parser, it will
    raise an exception and the lexer isn't free'd.  This patch moves the
    token checks up a little so that we can free the lexer before raising an
    exception.
    
    This program will leak memory without bounds:
    
    ```ruby
    require 'yajl'
    
    loop do
      begin
        stream = StringIO.new('foo')
        projector = Yajl::Projector.new(stream)
        projector.project({"name" => nil})
      rescue Yajl::ParseError
      end
    end
    ```
    tenderlove committed Dec 12, 2017
    Copy the full SHA
    b86a260 View commit details
    Browse the repository at this point in the history
  4. Pull token conditionals in to one place

    This commit removes token type check duplication.  Before this commit,
    all callers of `rb_yajl_projector_filter` would do the same token type
    checks that the body of the function would do.  This commit simply
    pushes the type checks down to the body of the function.
    tenderlove committed Dec 12, 2017
    Copy the full SHA
    6e69b5a View commit details
    Browse the repository at this point in the history
  5. fix segv on bad "simple values"

    The simple value de-serialization method seems to be missing some
    branches in its switch statement.  This adds a missing branch
    tenderlove committed Dec 12, 2017
    Copy the full SHA
    3ba7fcd View commit details
    Browse the repository at this point in the history
  6. Fix memory leak by protecting calls to the parser

    This program would exhibit unbounded memory growth:
    
    ```ruby
    loop do
      begin
        stream = StringIO.new('[,,,,,]')
        projector = Yajl::Projector.new(stream)
        projector.project({"name" => nil})
      rescue Yajl::ParseError
      end
    end
    ```
    
    This patch fixes it
    tenderlove committed Dec 12, 2017
    Copy the full SHA
    a09dd19 View commit details
    Browse the repository at this point in the history
  7. fix some clang warnings

    tenderlove committed Dec 12, 2017
    Copy the full SHA
    db10c28 View commit details
    Browse the repository at this point in the history
  8. fix another segv

    tenderlove committed Dec 12, 2017
    Copy the full SHA
    a5c4030 View commit details
    Browse the repository at this point in the history
  9. Make projection parser behave the same as regular parser

    The projection parser should raise the same exceptions that the regular
    JSON parser raises when parsing a bad document
    tenderlove committed Dec 12, 2017
    Copy the full SHA
    1e50529 View commit details
    Browse the repository at this point in the history