summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorcremno <[email protected]>2015-07-03 02:48:22 +0200
committercremno <[email protected]>2015-07-03 02:48:22 +0200
commit7206a8c4f91bd54390b6e244d6a32f9766b8e05f (patch)
tree1e024e320d065d9575f406f16b86e30769e9227f /src
parentff49cf95fca2d1648f05dd636c8f8516c8edc815 (diff)
downloadmruby-7206a8c4f91bd54390b6e244d6a32f9766b8e05f.tar.gz
mruby-7206a8c4f91bd54390b6e244d6a32f9766b8e05f.zip
fix dangling pointer
CID 75872 (#3-2 of 3): Pointer to local outside scope (RETURN_LOCAL) 38. use_invalid: Using p, which points to an out-of-scope variable buf.
Diffstat (limited to 'src')
-rw-r--r--src/string.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/string.c b/src/string.c
index 8df79d4c0..757317bdc 100644
--- a/src/string.c
+++ b/src/string.c
@@ -2057,6 +2057,7 @@ MRB_API double
mrb_cstr_to_dbl(mrb_state *mrb, const char * p, mrb_bool badcheck)
{
char *end;
+ char buf[DBL_DIG * 4 + 10];
double d;
enum {max_width = 20};
@@ -2077,7 +2078,6 @@ bad:
return d;
}
if (*end) {
- char buf[DBL_DIG * 4 + 10];
char *n = buf;
char *e = buf + sizeof(buf) - 1;
char prev = 0;