Thread
-
single a suggestion
PostgreSQL Bugs List <pgsql-bugs@postgresql.org> — 2001-02-06T06:11:31Z
KADIR ROJAS (ridak22@tutopia.com) reports a bug with a severity of 3 The lower the number the more severe it is. Short Description single a suggestion Long Description Hello from Panama. Working with pglib library, I discovered something, that could become a problem for the developers if they don't have strict control over what they are doing. It is the PQclear() function. When we call this function to release the assigned resources, and it has been called previously, it is not registered, causing a segmentation fault in the programs. I think that we could avoid some headaches to our programs, if we give a more robust form to the function, making a safer PQclear function. At the time of declaring the pointer to the structure it must be initialized in NULL (PQresult * res=NULL). This could guarantee that it won't accidentally release nonassigned resources. If we make this change the library itself would be able to have a registry of the calls to the function pqclear, so, the programmers wouldn't have to worry about this little issue and concentrate on other subjects. I'd like to know what do you think of this. thanks a lot for your attention. KJRC Sample Code /* Secure PQclear */ void SPQclear(PQresult **res) { if(*res) { PQclear(*res); *res = NULL; } return; } void main(void) { PQresult *res=NULL; . . . SPQclear(&res); . . . } No file was uploaded with this report