Re: Missing NULL check after calling ecpg_strdup

Поиск
Список
Период
Сортировка
От Aleksander Alekseev
Тема Re: Missing NULL check after calling ecpg_strdup
Дата
Msg-id CAJ7c6TMO9-aRrz80NbWQr-FFbTRTNh7WJkyWm=2NaXrV_y25uw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Missing NULL check after calling ecpg_strdup  (Aleksander Alekseev <aleksander@tigerdata.com>)
Ответы Re: Missing NULL check after calling ecpg_strdup
Список pgsql-hackers
Hi,

> OK, patch 0002 implements this idea with minimal changes to the existing logic.

Here is a slightly modified version:

``
--- a/src/interfaces/ecpg/ecpglib/prepare.c
+++ b/src/interfaces/ecpg/ecpglib/prepare.c
@@ -570,7 +570,7 @@ AddStmtToCache(int lineno,          /* line # of
statement */
        entry = &stmtCacheEntries[entNo];
        entry->lineno = lineno;
        entry->ecpgQuery = ecpg_strdup(ecpgQuery, lineno, &alloc_failed);
-       if (!entry->ecpgQuery)
+       if (alloc_failed)
                return -1;
        entry->connection = connection;
        entry->execs = 0;
```

We know that ecpgQuery can't be NULL because we hash its value above.
Thus ecpg_strdup can fail only if strdup() fails.

Вложения

В списке pgsql-hackers по дате отправления: