Skip to content

Commit

Permalink
Avoid modifying string literals
Browse files Browse the repository at this point in the history
When used in an environment frozen string literals (for example: RUBYOPT="--enable=frozen-string-literal") modifying "" raises exceptions. This fixes that, by switching to String.new.
  • Loading branch information
danielmorrison committed Dec 9, 2021
1 parent b3ed644 commit e885288
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/otnetstring.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class << self
def parse(io, encoding = 'internal', fallback_encoding = nil)
fallback_encoding = io.encoding if io.respond_to? :encoding
io = StringIO.new(io) if io.respond_to? :to_str
length, byte = "", nil
length, byte = String.new, nil

while byte.nil? || byte =~ /\d/
length << byte if byte
Expand Down
4 changes: 2 additions & 2 deletions lib/rb-fsevent/fsevent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ def run
while @running && IO::select([@pipe], nil, nil, nil)
# managing the IO ourselves allows us to be careful and never pass an
# incomplete message to OTNetstring.parse()
message = ""
length = ""
message = String.new
length = String.new
byte = nil

reading_length = true
Expand Down

0 comments on commit e885288

Please sign in to comment.