Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
5a020d41
Commit
5a020d41
authored
Jul 09, 2015
by
Joshua Haberman
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #575 from haberman/rbleak
Worked around memory leak bug in Ruby interpreter.
parents
ab2094de
8c717ad5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
1 deletion
+13
-1
encode_decode.c
ruby/ext/google/protobuf_c/encode_decode.c
+13
-1
No files found.
ruby/ext/google/protobuf_c/encode_decode.c
View file @
5a020d41
...
...
@@ -30,6 +30,18 @@
#include "protobuf.h"
// This function is equivalent to rb_str_cat(), but unlike the real
// rb_str_cat(), it doesn't leak memory in some versions of Ruby.
// For more information, see:
// https://bugs.ruby-lang.org/issues/11328
VALUE
noleak_rb_str_cat
(
VALUE
rb_str
,
const
char
*
str
,
long
len
)
{
size_t
oldlen
=
RSTRING_LEN
(
rb_str
);
rb_str_modify_expand
(
rb_str
,
len
);
char
*
p
=
RSTRING_PTR
(
rb_str
);
memcpy
(
p
+
oldlen
,
str
,
len
);
rb_str_set_len
(
rb_str
,
oldlen
+
len
);
}
// -----------------------------------------------------------------------------
// Parsing.
// -----------------------------------------------------------------------------
...
...
@@ -164,7 +176,7 @@ static size_t stringdata_handler(void* closure, const void* hd,
const
char
*
str
,
size_t
len
,
const
upb_bufhandle
*
handle
)
{
VALUE
rb_str
=
(
VALUE
)
closure
;
rb_str_cat
(
rb_str
,
str
,
len
);
noleak_
rb_str_cat
(
rb_str
,
str
,
len
);
return
len
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment