Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
dc18042e
Commit
dc18042e
authored
Dec 09, 2012
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #606 from masamitsu-murase/fix_memory_leak_in_string_to_i
Fix memory leak in String#to_i and String#to_f.
parents
453980d7
a7182c20
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
11 deletions
+4
-11
src/string.c
src/string.c
+4
-11
No files found.
src/string.c
View file @
dc18042e
...
@@ -2544,12 +2544,8 @@ mrb_str_to_inum(mrb_state *mrb, mrb_value str, int base, int badcheck)
...
@@ -2544,12 +2544,8 @@ mrb_str_to_inum(mrb_state *mrb, mrb_value str, int base, int badcheck)
if
(
s
)
{
if
(
s
)
{
len
=
RSTRING_LEN
(
str
);
len
=
RSTRING_LEN
(
str
);
if
(
s
[
len
])
{
/* no sentinel somehow */
if
(
s
[
len
])
{
/* no sentinel somehow */
char
*
p
=
(
char
*
)
mrb_malloc
(
mrb
,
len
+
1
);
struct
RString
*
temp_str
=
str_new
(
mrb
,
s
,
len
);
s
=
temp_str
->
ptr
;
//MEMCPY(p, s, char, len);
memcpy
(
p
,
s
,
len
);
p
[
len
]
=
'\0'
;
s
=
p
;
}
}
}
}
return
mrb_cstr_to_inum
(
mrb
,
s
,
base
,
badcheck
);
return
mrb_cstr_to_inum
(
mrb
,
s
,
base
,
badcheck
);
...
@@ -2681,11 +2677,8 @@ mrb_str_to_dbl(mrb_state *mrb, mrb_value str, int badcheck)
...
@@ -2681,11 +2677,8 @@ mrb_str_to_dbl(mrb_state *mrb, mrb_value str, int badcheck)
mrb_raise
(
mrb
,
E_ARGUMENT_ERROR
,
"string for Float contains null byte"
);
mrb_raise
(
mrb
,
E_ARGUMENT_ERROR
,
"string for Float contains null byte"
);
}
}
if
(
s
[
len
])
{
/* no sentinel somehow */
if
(
s
[
len
])
{
/* no sentinel somehow */
char
*
p
=
(
char
*
)
mrb_malloc
(
mrb
,
len
+
1
);
struct
RString
*
temp_str
=
str_new
(
mrb
,
s
,
len
);
s
=
temp_str
->
ptr
;
memcpy
(
p
,
s
,
len
);
p
[
len
]
=
'\0'
;
s
=
p
;
}
}
}
}
return
mrb_cstr_to_dbl
(
mrb
,
s
,
badcheck
);
return
mrb_cstr_to_dbl
(
mrb
,
s
,
badcheck
);
...
...
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