• R/O
  • SSH
  • HTTPS

yash: 提交


Commit MetaInfo

修訂4183 (tree)
時間2021-12-18 15:34:50
作者magicant

Log Message

Avoid crash with empty array

Change Summary

差異

--- yash/trunk/parser.c (revision 4182)
+++ yash/trunk/parser.c (revision 4183)
@@ -3972,7 +3972,10 @@
39723972 }
39733973
39743974 size_t save_count = pr->pending_heredocs.length;
3975- void *save_heredocs[save_count];
3975+ size_t extended_count = save_count;
3976+ if (extended_count == 0)
3977+ extended_count = 1; // A variable-length array must not be empty.
3978+ void *save_heredocs[extended_count];
39763979 memcpy(save_heredocs, pr->pending_heredocs.contents, sizeof save_heredocs);
39773980 pl_truncate(&pr->pending_heredocs, 0);
39783981
--- yash/trunk/variable.c (revision 4182)
+++ yash/trunk/variable.c (revision 4183)
@@ -2123,7 +2123,10 @@
21232123 void array_remove_elements(
21242124 variable_T *array, size_t count, void *const *indexwcss)
21252125 {
2126- long indices[count];
2126+ size_t extended_count = count;
2127+ if (extended_count == 0)
2128+ extended_count = 1; // A variable-length array must ot be empty.
2129+ long indices[extended_count];
21272130
21282131 assert((array->v_type & VF_MASK) == VF_ARRAY);
21292132
Show on old repository browser