summaryrefslogtreecommitdiffhomepage
path: root/src/codegen.c
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2014-06-14 01:01:25 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2014-06-14 01:01:25 +0900
commite4b01da97ea28ad1c13f848c55c73dc1cc080760 (patch)
tree5f631219d3119999d87f52d09e23c9626cd1ab9d /src/codegen.c
parent774703c5d786519052d096449d544081443c511d (diff)
parent61032c5ab03ee9d71875b8cb63c7cd5702d56ff7 (diff)
downloadmruby-e4b01da97ea28ad1c13f848c55c73dc1cc080760.tar.gz
mruby-e4b01da97ea28ad1c13f848c55c73dc1cc080760.zip
Merge pull request #2393 from goyox86/fix-clang-analizer-warnings
Fix clang analizer warnings
Diffstat (limited to 'src/codegen.c')
-rw-r--r--src/codegen.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/src/codegen.c b/src/codegen.c
index c7b8e2d74..03c752826 100644
--- a/src/codegen.c
+++ b/src/codegen.c
@@ -475,6 +475,8 @@ new_msym(codegen_scope *s, mrb_sym sym)
{
size_t i, len;
+ mrb_assert(s->irep);
+
len = s->irep->slen;
if (len > 256) len = 256;
for (i=0; i<len; i++) {
@@ -1106,21 +1108,23 @@ readint_mrb_int(codegen_scope *s, const char *p, int base, mrb_bool neg, mrb_boo
codegen_error(s, "malformed readint input");
}
- if (neg) {
- if ((MRB_INT_MIN + n)/base > result) {
- *overflow = TRUE;
- return 0;
+ if(base > 0) {
+ if (neg) {
+ if ((MRB_INT_MIN + n)/base > result) {
+ *overflow = TRUE;
+ return 0;
+ }
+ result *= base;
+ result -= n;
}
- result *= base;
- result -= n;
- }
- else {
- if ((MRB_INT_MAX - n)/base < result) {
- *overflow = TRUE;
- return 0;
+ else {
+ if ((MRB_INT_MAX - n)/base < result) {
+ *overflow = TRUE;
+ return 0;
+ }
+ result *= base;
+ result += n;
}
- result *= base;
- result += n;
}
p++;
}