This patch makes some of the memory manipulation performed by psql a little more sane. Some parts of the code was using a static function xmalloc() that did safe memory allocation (where "safe" means "bail out on OOM"), but most of it was just invoking calloc() or malloc() directly. So I moved xmalloc() and xmalloc_zero() to be public (within psql) functions, and added a new xcalloc(), then changed (almost) all the call sites of calloc(), malloc(), and strdup() to use the safer versions (there was previously an xstrdup(), but there were still some call sites that used strdup() directly). Most of the call sites of malloc() et al. that I replaced tried to do something "intelligent" if OOM occurred, like returning NULL or false depending on the function. ISTM that is just a waste of cycles, and may actually cause more problems: for example, this practise might result in returning a NULL pointer to a caller that isn't expecting one -- so OOM would result in a core dump rather than an error message & a clean exit. So I just ripped all that out and replaced it with the new functions, which always bail out on OOM. Unless anyone objects, I intend to apply this within 24 hours. -Neil
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера