Add NULL-check, to silence a Coverity problem.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Thu, 18 Apr 2013 19:35:20 +0000 (22:35 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Thu, 18 Apr 2013 19:35:20 +0000 (22:35 +0300)
The problem is that if the loop above doesn't find a result set with
command tag "FETCH ...", res is left to point to an already-freed result
set, and we'll go ahead and call QR_set_withhold on the already-freed
struct. That can't happen in practice, because the backend does always
return a result set with "FETCH ..." command tag when a FETCH statement is
issued, but better safe than sorry.

statement.c

index b8c340911ba58cf6bb0cddfdd06cf743b7913946..eea40a12bfc03b844c358376350324a703556682 100644 (file)
@@ -1992,7 +1992,7 @@ inolog("get_Result=%p %p %d\n", res, SC_get_Result(self), self->curr_param_resul
                    qres = nres;
                }
            }   
-           if (SC_is_with_hold(self))
+           if (res && SC_is_with_hold(self))
                QR_set_withhold(res);
        }
        mylog("     done sending the query:\n");