Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfb30c9c

Browse files
committed
In pg_log_generic(), be more paranoid about preserving errno.
This code failed to account for the possibility that malloc() wouldchange errno, resulting in wrong output for %m, not to mention thepossibility of message truncation. Such a change is obviouslyexpected when malloc fails, but there's reason to fear that on someplatforms even a successful malloc call can modify errno.Discussion:https://postgr.es/m/2576.1527382833@sss.pgh.pa.us
1 parentb33283c commitfb30c9c

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

‎src/common/logging.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@ pg_log_generic_v(enum pg_log_level level, const char *pg_restrict fmt, va_list a
216216

217217
buf=pg_malloc_extended(required_len,MCXT_ALLOC_NO_OOM);
218218

219+
errno=save_errno;/* malloc might change errno */
220+
219221
if (!buf)
220222
{
221223
/* memory trouble, just print what we can and get out of here */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp