Re: Missing NULL check after calling ecpg_strdup
От | Aleksander Alekseev |
---|---|
Тема | Re: Missing NULL check after calling ecpg_strdup |
Дата | |
Msg-id | CAJ7c6TNX+sL6YLdOVcaHhh_aXQzC3ggfw8vcygJhrNbSzcNEig@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: Missing NULL check after calling ecpg_strdup (Michael Paquier <michael@paquier.xyz>) |
Ответы |
Re: Missing NULL check after calling ecpg_strdup
|
Список | pgsql-hackers |
Hi, > I have spent some time rechecking the whole code, and I have > backpatched this part. [...] Many thanks! > Hmm.. Aren't you missing a va_end(args) in the early exit you are > adding here? I do, and it's rather stupid of me. Thanks. > [...] > At the end, I finish with the attached, where alloc_failed matters for > the failure checks with repeated calls of strdup() in ECPGconnect() > and also the setlocale() case. This is for HEAD due to how unlikely > these issues would occur in practice. v7 may have a compilation warning on Linux: ``` warning: unused variable ‘alloc_failed’ [-Wunused-variable] ``` ... because the only use of the variable is hidden under #ifdef's. Fixed in v8: ``` --- a/src/interfaces/ecpg/ecpglib/descriptor.c +++ b/src/interfaces/ecpg/ecpglib/descriptor.c @@ -240,9 +240,9 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...) act_tuple; struct variable data_var; struct sqlca_t *sqlca = ECPGget_sqlca(); - bool alloc_failed = false; + bool alloc_failed = (sqlca == NULL); - if (sqlca == NULL) + if (alloc_failed) { ecpg_raise(lineno, ECPG_OUT_OF_MEMORY, ECPG_SQLSTATE_ECPG_OUT_OF_MEMORY, NULL); ``` This code is also more consistent with what we ended up having in connect.c. Other than that the patch looks OK to me.
Вложения
В списке pgsql-hackers по дате отправления: