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
270d25bf
Commit
270d25bf
authored
Mar 08, 2014
by
Masaki Muranaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make type casts safer.
parent
058bb18f
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
245 additions
and
151 deletions
+245
-151
include/mruby/dump.h
include/mruby/dump.h
+3
-3
include/mruby/string.h
include/mruby/string.h
+1
-1
mrbgems/mruby-proc-ext/src/proc.c
mrbgems/mruby-proc-ext/src/proc.c
+1
-1
src/class.c
src/class.c
+4
-1
src/codegen.c
src/codegen.c
+5
-2
src/dump.c
src/dump.c
+156
-99
src/load.c
src/load.c
+70
-43
src/string.c
src/string.c
+5
-1
No files found.
include/mruby/dump.h
View file @
270d25bf
...
...
@@ -92,14 +92,14 @@ struct rite_binary_footer {
RITE_SECTION_HEADER
;
};
static
inline
in
t
static
inline
size_
t
uint8_to_bin
(
uint8_t
s
,
uint8_t
*
bin
)
{
*
bin
=
s
;
return
sizeof
(
uint8_t
);
}
static
inline
in
t
static
inline
size_
t
uint16_to_bin
(
uint16_t
s
,
uint8_t
*
bin
)
{
*
bin
++
=
(
s
>>
8
)
&
0xff
;
...
...
@@ -107,7 +107,7 @@ uint16_to_bin(uint16_t s, uint8_t *bin)
return
sizeof
(
uint16_t
);
}
static
inline
in
t
static
inline
size_
t
uint32_to_bin
(
uint32_t
l
,
uint8_t
*
bin
)
{
*
bin
++
=
(
l
>>
24
)
&
0xff
;
...
...
include/mruby/string.h
View file @
270d25bf
...
...
@@ -15,7 +15,7 @@ extern "C" {
extern
const
char
mrb_digitmap
[];
#define RSTRING_EMBED_LEN_MAX (
sizeof(void*) * 3 - 1
)
#define RSTRING_EMBED_LEN_MAX (
(mrb_int)(sizeof(void*) * 3 - 1)
)
struct
RString
{
MRB_OBJECT_HEADER
;
...
...
mrbgems/mruby-proc-ext/src/proc.c
View file @
270d25bf
...
...
@@ -21,7 +21,7 @@ mrb_proc_source_location(mrb_state *mrb, mrb_value self)
}
else
{
mrb_irep
*
irep
=
p
->
body
.
irep
;
u
int32_t
line
;
int32_t
line
;
const
char
*
filename
;
filename
=
mrb_debug_get_filename
(
irep
,
0
);
...
...
src/class.c
View file @
270d25bf
...
...
@@ -533,9 +533,12 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
ps
=
va_arg
(
ap
,
char
**
);
if
(
i
<
argc
)
{
size_t
size_t_len
;
ss
=
to_str
(
mrb
,
*
sp
++
);
s
=
mrb_str_ptr
(
ss
);
len
=
(
mrb_int
)
strlen
(
RSTRING_PTR
(
ss
));
size_t_len
=
strlen
(
RSTRING_PTR
(
ss
));
mrb_assert
(
size_t_len
<=
MRB_INT_MAX
);
len
=
(
mrb_int
)
size_t_len
;
if
(
len
<
RSTRING_LEN
(
ss
))
{
mrb_raise
(
mrb
,
E_ARGUMENT_ERROR
,
"string contains null byte"
);
}
...
...
src/codegen.c
View file @
270d25bf
...
...
@@ -5,6 +5,7 @@
*/
#include <ctype.h>
#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include "mruby.h"
...
...
@@ -2582,14 +2583,16 @@ static void
codedump
(
mrb_state
*
mrb
,
mrb_irep
*
irep
)
{
#ifdef ENABLE_STDIO
uint32_
t
i
;
in
t
i
;
int
ai
;
mrb_code
c
;
if
(
!
irep
)
return
;
printf
(
"irep %p nregs=%d nlocals=%d pools=%d syms=%d reps=%d
\n
"
,
irep
,
irep
->
nregs
,
irep
->
nlocals
,
(
int
)
irep
->
plen
,
(
int
)
irep
->
slen
,
(
int
)
irep
->
rlen
);
for
(
i
=
0
;
i
<
irep
->
ilen
;
i
++
)
{
mrb_assert
(
irep
->
ilen
<=
INT_MAX
);
for
(
i
=
0
;
i
<
(
int
)(
irep
->
ilen
);
i
++
)
{
ai
=
mrb_gc_arena_save
(
mrb
);
printf
(
"%03d "
,
i
);
c
=
irep
->
iseq
[
i
];
...
...
src/dump.c
View file @
270d25bf
This diff is collapsed.
Click to expand it.
src/load.c
View file @
270d25bf
This diff is collapsed.
Click to expand it.
src/string.c
View file @
270d25bf
...
...
@@ -2067,8 +2067,12 @@ mrb_string_value_cstr(mrb_state *mrb, mrb_value *ptr)
{
struct
RString
*
ps
=
mrb_str_ptr
(
*
ptr
);
char
*
s
=
STR_PTR
(
ps
);
mrb_int
len
;
if
(
!
s
||
STR_LEN
(
ps
)
!=
strlen
(
s
))
{
len
=
STR_LEN
(
ps
);
mrb_assert
(
len
>=
0
);
mrb_assert
((
size_t
)
len
<=
SIZE_MAX
);
if
(
!
s
||
(
size_t
)
len
!=
strlen
(
s
))
{
mrb_raise
(
mrb
,
E_ARGUMENT_ERROR
,
"string contains null byte"
);
}
return
s
;
...
...
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