8000 Rebase to master - fix-up memory allocation and access mistakes · gurjeet/postgres@5e5ccb4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5e5ccb4

Browse files
committed
Rebase to master - fix-up memory allocation and access mistakes
There was an unnecessary allocation, and removing that exposed the unnecessary indirection of a pointer value. The use of malloc in Postgres is restricted to very few places, and since the GUC checking and setting code has a dedicated memory context, use guc_malloc() for memory allocations.
1 parent 447e5e3 commit 5e5ccb4

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/backend/commands/variable.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1293,17 +1293,14 @@ check_password_duration(char **newval, void **extra, GucSource source)
12931293
return false;
12941294
}
12951295

1296-
new_interval = malloc(sizeof(Interval));
1296+
new_interval = guc_malloc(LOG, sizeof(Interval));
12971297
memcpy(new_interval, interval, sizeof(Interval));
12981298
pfree(interval);
12991299

13001300
/*
13011301
* Pass back data for assign_password_validity to use
13021302
*/
1303-
*extra = malloc(sizeof(Interval *));
1304-
if (!*extra)
1305-
return false;
1306-
*((Interval **) *extra) = new_interval;
1303+
*extra = (void*) new_interval;
13071304

13081305
return true;
13091306
}
@@ -1317,7 +1314,7 @@ assign_password_duration(const char *newval, void *extra)
13171314
if (extra == NULL)
13181315
default_password_duration = NULL;
13191316
else
1320-
default_password_duration = *((Interval **) extra);
1317+
default_password_duration = (Interval *) extra;
13211318
}
13221319

13231320
/*

0 commit comments

Comments
 (0)
0