Skip to content

Commit 8b36bda

Browse files
author
Nikita Glukhov
committed
Use palloc0() instead of palloc()
1 parent c9adab6 commit 8b36bda

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/backend/utils/adt/jsonfuncs.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4165,20 +4165,19 @@ jsonb_set_element(Datum jsonbdatum, text **path, int path_len,
41654165
*res = NULL;
41664166
JsonbParseState *state = NULL;
41674167
JsonbIterator *it;
4168-
int i = 0;
4169-
bool *path_nulls = palloc(path_len * sizeof(bool));
4168+
bool *path_nulls = palloc0(path_len * sizeof(bool));
41704169

41714170
newval = to_jsonb_worker(sourceData, source_type);
41724171
it = JsonbIteratorInit(&jb->root);
41734172

41744173
if (newval->type == jbvArray && newval->val.array.rawScalar == true)
41754174
*newval = newval->val.array.elems[0];
41764175

4177-
for (i = 0; i < path_len; i++)
4178-
path_nulls[i] = false;
41794176

41804177
res = setPath(&it, (Datum *) path, path_nulls, path_len, &state, 0,
41814178
newval, JB_PATH_CREATE);
41824179

4180+
pfree(path_nulls);
4181+
41834182
PG_RETURN_JSONB(JsonbValueToJsonb(res));
41844183
}

0 commit comments

Comments
 (0)