diff --git a/HISTORY b/HISTORY index 8cd1bc5..838dd78 100755 --- a/HISTORY +++ b/HISTORY @@ -1,3 +1,6 @@ +Mar. 15 2016 +Improved error promption of array manipulation + Mar. 11 2016 Improved error promption diff --git a/core/my_basic.c b/core/my_basic.c index d8e8431..892341f 100755 --- a/core/my_basic.c +++ b/core/my_basic.c @@ -11111,6 +11111,16 @@ int mb_init_array(struct mb_interpreter_t* s, void** l, mb_data_e t, int* d, int mb_assert(s && l && d && a); *a = 0; + if(c >= MB_MAX_DIMENSION_COUNT) { + _handle_error_on_obj(s, SE_RN_DIMENSION_TOO_MUCH, s->source_file, TON(l), MB_FUNC_ERR, _exit, result); + } + for(j = 0; j < c; j++) { + n = d[j]; + if(n <= 0) { + _handle_error_on_obj(s, SE_RN_ILLEGAL_BOUND, s->source_file, TON(l), MB_FUNC_ERR, _exit, result); + } + } + #ifdef MB_SIMPLE_ARRAY if(t == MB_DT_REAL) { type = _DT_REAL; @@ -11130,9 +11140,9 @@ int mb_init_array(struct mb_interpreter_t* s, void** l, mb_data_e t, int* d, int n = d[j]; arr->dimensions[arr->dimension_count++] = n; if(arr->count) - arr->count *= n; + arr->count *= (unsigned int)n; else - arr->count += n; + arr->count += (unsigned int)n; } _init_array(arr); if(!arr->raw) { @@ -11142,8 +11152,6 @@ int mb_init_array(struct mb_interpreter_t* s, void** l, mb_data_e t, int* d, int } *a = arr; - goto _exit; /* Avoid an unreferenced label warning */ - _exit: return result; }