Skip to content

Commit 8df054d

Browse files
committed
Merge branch 'REL9_5_STABLE' into PGPRO9_5
Merge fixes up to 29.02.16
2 parents 8b364f0 + 2d43c45 commit 8df054d

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

src/backend/utils/adt/pg_locale.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -387,9 +387,6 @@ assign_locale_messages(const char *newval, void *extra)
387387
static void
388388
free_struct_lconv(struct lconv * s)
389389
{
390-
if (s == NULL)
391-
return;
392-
393390
if (s->currency_symbol)
394391
free(s->currency_symbol);
395392
if (s->decimal_point)
@@ -441,6 +438,7 @@ struct lconv *
441438
PGLC_localeconv(void)
442439
{
443440
static struct lconv CurrentLocaleConv;
441+
static bool CurrentLocaleConvAllocated = false;
444442
struct lconv *extlconv;
445443
char *save_lc_monetary;
446444
char *save_lc_numeric;
@@ -457,7 +455,12 @@ PGLC_localeconv(void)
457455
if (CurrentLocaleConvValid)
458456
return &CurrentLocaleConv;
459457

460-
free_struct_lconv(&CurrentLocaleConv);
458+
/* Free any already-allocated storage */
459+
if (CurrentLocaleConvAllocated)
460+
{
461+
free_struct_lconv(&CurrentLocaleConv);
462+
CurrentLocaleConvAllocated = false;
463+
}
461464

462465
/* Save user's values of monetary and numeric locales */
463466
save_lc_monetary = setlocale(LC_MONETARY, NULL);
@@ -521,7 +524,9 @@ PGLC_localeconv(void)
521524

522525
/*
523526
* Must copy all values since restoring internal settings may overwrite
524-
* localeconv()'s results.
527+
* localeconv()'s results. Note that if we were to fail within this
528+
* sequence before reaching "CurrentLocaleConvAllocated = true", we could
529+
* leak some memory --- but not much, so it's not worth agonizing over.
525530
*/
526531
CurrentLocaleConv = *extlconv;
527532
CurrentLocaleConv.decimal_point = decimal_point;
@@ -534,6 +539,7 @@ PGLC_localeconv(void)
534539
CurrentLocaleConv.mon_thousands_sep = db_encoding_strdup(encoding, extlconv->mon_thousands_sep);
535540
CurrentLocaleConv.negative_sign = db_encoding_strdup(encoding, extlconv->negative_sign);
536541
CurrentLocaleConv.positive_sign = db_encoding_strdup(encoding, extlconv->positive_sign);
542+
CurrentLocaleConvAllocated = true;
537543

538544
/* Try to restore internal settings */
539545
if (save_lc_monetary)

src/include/replication/reorderbuffer.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ typedef struct ReorderBufferChange
7878
RepOriginId origin_id;
7979

8080
/*
81-
* Context data for the change, which part of the union is valid depends
82-
* on action/action_internal.
81+
* Context data for the change. Which part of the union is valid depends
82+
* on action.
8383
*/
8484
union
8585
{
@@ -245,7 +245,7 @@ typedef struct ReorderBufferTXN
245245
/* ---
246246
* Position in one of three lists:
247247
* * list of subtransactions if we are *known* to be subxact
248-
* * list of toplevel xacts (can be am as-yet unknown subxact)
248+
* * list of toplevel xacts (can be an as-yet unknown subxact)
249249
* * list of preallocated ReorderBufferTXNs
250250
* ---
251251
*/
@@ -283,7 +283,7 @@ struct ReorderBuffer
283283

284284
/*
285285
* Transactions that could be a toplevel xact, ordered by LSN of the first
286-
* record bearing that xid..
286+
* record bearing that xid.
287287
*/
288288
dlist_head toplevel_by_lsn;
289289

@@ -295,7 +295,7 @@ struct ReorderBuffer
295295
ReorderBufferTXN *by_txn_last_txn;
296296

297297
/*
298-
* Callacks to be called when a transactions commits.
298+
* Callbacks to be called when a transactions commits.
299299
*/
300300
ReorderBufferBeginCB begin;
301301
ReorderBufferApplyChangeCB apply_change;
@@ -318,7 +318,7 @@ struct ReorderBuffer
318318
* overhead we cache some unused ones here.
319319
*
320320
* The maximum number of cached entries is controlled by const variables
321-
* ontop of reorderbuffer.c
321+
* on top of reorderbuffer.c
322322
*/
323323

324324
/* cached ReorderBufferTXNs */

0 commit comments

Comments
 (0)