Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes from PVS-Studio #2032

Closed
wants to merge 1 commit into from
Closed

fixes from PVS-Studio #2032

wants to merge 1 commit into from

Conversation

ip-gpu
Copy link

@ip-gpu ip-gpu commented Oct 30, 2017

I'm a member of the Pinguem.ru competition on finding errors in open source projects. A bug, found using PVS-Studio. Warnings:

V522 Dereferencing of the null pointer 'pv' might take place. cookie.c 316

V522 Dereferencing of the null pointer 'pv' might take place. cookie.c 316
@bagder
Copy link
Member

bagder commented Oct 30, 2017

CI failures because it doesn't follow our code style. But more importantly, shouldn't the fix rather be?

--- a/lib/cookie.c
+++ b/lib/cookie.c
@@ -307,11 +307,11 @@ static void remove_expired(struct CookieInfo *cookies)
   co = cookies->cookies;
   pv = NULL;
   while(co) {
     nx = co->next;
     if(co->expires && co->expires < now) {
-      if(co == cookies->cookies) {
+      if(!pv) {
         cookies->cookies = co->next;
       }
       else {
         pv->next = co->next;
       }

bagder added a commit that referenced this pull request Oct 30, 2017
... when expiring old cookies.

Reported-by: Pavel Gushchin
Fixes #2032
@bagder bagder closed this in fa394c8 Oct 31, 2017
@lock lock bot locked as resolved and limited conversation to collaborators Jan 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants