浏览代码

ncd: NCDModule: fix crash if _argN special object in a process for arguments that don't exist (N is too large)

ambrop7 13 年之前
父节点
当前提交
b7cc052f96
共有 1 个文件被更改,包括 4 次插入2 次删除
  1. 4 2
      ncd/NCDModule.c

+ 4 - 2
ncd/NCDModule.c

@@ -541,8 +541,10 @@ int NCDModuleProcess_Interp_GetSpecialObj (NCDModuleProcess *o, NCD_string_id_t
         
         if (name >= NCD_STRING_ARG0 && name <= NCD_STRING_ARG19) {
             int num = name - NCD_STRING_ARG0;
-            *out_object = NCDObject_Build2(-1, o, (void *)((uintptr_t)(num + 1)), (NCDObject_func_getvar2)process_arg_object_func_getvar2, NULL);
-            return 1;
+            if (num < NCDVal_ListCount(o->args)) {
+                *out_object = NCDObject_Build2(-1, o, (void *)((uintptr_t)(num + 1)), (NCDObject_func_getvar2)process_arg_object_func_getvar2, NULL);
+                return 1;
+            }
         }
     }