Skip to content

Conversation

@yanjiew1
Copy link
Contributor

In do_reverseK, we should check whether current is NULL before dereferencing current. We should not dereference it if it is NULL.

In `do_reverseK`, we should check whether `current` is NULL before
dereferencing `current`. We should not dereference it if it is NULL.
@jserv jserv requested a review from eecheng87 February 16, 2023 14:47
@eecheng87
Copy link
Collaborator

Hi @yanjiew1 ,

There actually are several do_.* functions lack of null-pointer detection, can you also consolidate them in this commit?
Also, can you make the detection be consistent to other functions? For example:

static bool do_reverse(int argc, char *argv[])
{
...

    if (!current || !current->q)
        report(3, "Warning: Calling reverse on null queue");
...
}

Thanks.

@yanjiew1
Copy link
Contributor Author

Pull request #125 has already fixed this problem.

@yanjiew1 yanjiew1 closed this Feb 22, 2023
@yanjiew1 yanjiew1 deleted the reverseK_crash_on_null branch February 22, 2023 01:28
@yanjiew1 yanjiew1 restored the reverseK_crash_on_null branch February 22, 2023 01:28
@yanjiew1 yanjiew1 deleted the reverseK_crash_on_null branch February 22, 2023 01:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants