Skip to content

Commit ac39a49

Browse files
committed
Access unknown address when sorting a null queue
1 parent cac7abd commit ac39a49

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

qtest.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,8 +466,8 @@ static bool do_size(int argc, char *argv[])
466466

467467
bool do_sort(int argc, char *argv[])
468468
{
469-
if (argc != 1) {
470-
report(1, "%s takes no arguments", argv[0]);
469+
if (argc != 1 && argc != 2) {
470+
report(1, "%s takes 0-1 arguments", argv[0]);
471471
return false;
472472
}
473473

@@ -485,6 +485,8 @@ bool do_sort(int argc, char *argv[])
485485
exception_cancel();
486486
set_noallocate_mode(false);
487487

488+
if (argc == 2)
489+
return true;
488490
list_ele_t *e = q->head;
489491
bool ok = true;
490492
while (ok && e && --cnt) {

traces/trace-07-robust.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ it dolphin
77
rh
88
reverse
99
size
10-
sort
10+
sort NULL

0 commit comments

Comments
 (0)