Просмотр исходного кода

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

ambrop7 13 лет назад
Родитель
Сommit
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;
+            }
         }
     }