diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-01-21 12:22:54 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-01-21 12:22:54 +0900 |
| commit | 5e0f51c906d588fe13bcb47fe563a28deeec1675 (patch) | |
| tree | 9fce0f9139a4826c3a885682f0c25a427be6c5a4 /mrbgems | |
| parent | 47a68e89ffcfcacb4a0c6c64c3b2ab69ee4da35f (diff) | |
| download | mruby-5e0f51c906d588fe13bcb47fe563a28deeec1675.tar.gz mruby-5e0f51c906d588fe13bcb47fe563a28deeec1675.zip | |
Silence gcc warning from `strncpy()`.
Diffstat (limited to 'mrbgems')
| -rw-r--r-- | mrbgems/mruby-bin-debugger/tools/mrdb/apibreak.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/mrbgems/mruby-bin-debugger/tools/mrdb/apibreak.c b/mrbgems/mruby-bin-debugger/tools/mrdb/apibreak.c index 1507926f2..4d139aa76 100644 --- a/mrbgems/mruby-bin-debugger/tools/mrdb/apibreak.c +++ b/mrbgems/mruby-bin-debugger/tools/mrdb/apibreak.c @@ -173,6 +173,7 @@ mrb_debug_set_break_line(mrb_state *mrb, mrb_debug_context *dbg, const char *fil int32_t index; char* set_file; uint16_t result; + size_t len; if ((mrb == NULL)||(dbg == NULL)||(file == NULL)) { return MRB_DEBUG_INVALID_ARGUMENT; @@ -195,7 +196,8 @@ mrb_debug_set_break_line(mrb_state *mrb, mrb_debug_context *dbg, const char *fil return MRB_DEBUG_BREAK_INVALID_LINENO; } - set_file = (char*)mrb_malloc(mrb, strlen(file) + 1); + len = strlen(file) + 1; + set_file = (char*)mrb_malloc(mrb, len); index = dbg->bpnum; dbg->bp[index].bpno = dbg->next_bpno; @@ -205,7 +207,7 @@ mrb_debug_set_break_line(mrb_state *mrb, mrb_debug_context *dbg, const char *fil dbg->bp[index].point.linepoint.lineno = lineno; dbg->bpnum++; - strncpy(set_file, file, strlen(file) + 1); + strncpy(set_file, file, len); dbg->bp[index].point.linepoint.file = set_file; @@ -218,6 +220,7 @@ mrb_debug_set_break_method(mrb_state *mrb, mrb_debug_context *dbg, const char *c int32_t index; char* set_class; char* set_method; + size_t len; if ((mrb == NULL) || (dbg == NULL) || (method_name == NULL)) { return MRB_DEBUG_INVALID_ARGUMENT; @@ -232,16 +235,18 @@ mrb_debug_set_break_method(mrb_state *mrb, mrb_debug_context *dbg, const char *c } if (class_name != NULL) { - set_class = (char*)mrb_malloc(mrb, strlen(class_name) + 1); - strncpy(set_class, class_name, strlen(class_name) + 1); + len = strlen(class_name) + 1; + set_class = (char*)mrb_malloc(mrb, len); + strncpy(set_class, class_name, len); } else { set_class = NULL; } - set_method = (char*)mrb_malloc(mrb, strlen(method_name) + 1); + len = strlen(method_name) + 1; + set_method = (char*)mrb_malloc(mrb, len); - strncpy(set_method, method_name, strlen(method_name) + 1); + strncpy(set_method, method_name, len); index = dbg->bpnum; dbg->bp[index].bpno = dbg->next_bpno; |
