Browse Source

v.random: Fix segfault as per bug #1024 (#1025)

cats_array memory is allocated only when fields for parm.input->answer are > 0

Co-authored-by: Māris Nartišs <maris.nartiss@lu.lv>
Māris Nartišs 4 năm trước cách đây
mục cha
commit
c3ad638ef5
1 tập tin đã thay đổi với 1 bổ sung1 xóa
  1. 1 1
      vector/v.random/main.c

+ 1 - 1
vector/v.random/main.c

@@ -667,7 +667,7 @@ int main(int argc, char *argv[])
             cat = i + 1;
             
             if (!notable) {
-                if (parm.input->answer) {
+                if (parm.input->answer && field > 0) {
                     Vect_cat_get(Cats, field, &cat_area);
 
                     cats_array[i].cat = cat;