-
Notifications
You must be signed in to change notification settings - Fork 401
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix sanitizer errors #1266
base: master
Are you sure you want to change the base?
Fix sanitizer errors #1266
Changes from all commits
de3633d
3afbad6
2840ce1
71f445a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6760,7 +6760,7 @@ static FuncExpr *make_clause_func_expr(char *function_name, | |
*/ | ||
outNode(str, clause_information); | ||
|
||
clause_information_const = makeConst(INTERNALOID, -1, InvalidOid, str->len, | ||
clause_information_const = makeConst(INTERNALOID, -1, InvalidOid, str->len + 1, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please justify why there needs to be an additional +1 to the length? |
||
PointerGetDatum(str->data), false, false); | ||
|
||
func_oid = get_ag_func_oid(function_name, 1, INTERNALOID); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9043,7 +9043,7 @@ agtype_value *agtype_composite_to_agtype_value_binary(agtype *a) | |
errmsg("cannot convert agtype scalar objects to binary agtype_value objects"))); | ||
} | ||
|
||
result = palloc(sizeof(agtype_value)); | ||
result = palloc0(sizeof(agtype_value)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While it is generally good form to pre-initialize to zero, is it really necessary if the routine that uses it, sets it up properly? In the case of these iterator functions, which are generally slow, it takes up additional cpu cycles. So, I'm not sure this is necessary. Can you justify adding this? |
||
|
||
// convert the agtype to a binary agtype_value | ||
result->type = AGTV_BINARY; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,7 +59,7 @@ bool ag_serialize_extended_type(StringInfo buffer, agtentry *agtentry, | |
/* copy in the int_value data */ | ||
numlen = sizeof(int64); | ||
offset = reserve_from_buffer(buffer, numlen); | ||
*((int64 *)(buffer->data + offset)) = scalar_val->val.int_value; | ||
memcpy( buffer->data + offset, &scalar_val->val.int_value, numlen); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see why this is necessary, maybe it is just me, could you please elaborate? |
||
|
||
*agtentry = AGTENTRY_IS_AGTYPE | (padlen + numlen + AGT_HEADER_SIZE); | ||
break; | ||
|
@@ -70,7 +70,7 @@ bool ag_serialize_extended_type(StringInfo buffer, agtentry *agtentry, | |
/* copy in the float_value data */ | ||
numlen = sizeof(scalar_val->val.float_value); | ||
offset = reserve_from_buffer(buffer, numlen); | ||
*((float8 *)(buffer->data + offset)) = scalar_val->val.float_value; | ||
memcpy(buffer->data + offset, &scalar_val->val.int_value, numlen); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see why this is necessary, maybe it is just me, could you please elaborate? |
||
|
||
*agtentry = AGTENTRY_IS_AGTYPE | (padlen + numlen + AGT_HEADER_SIZE); | ||
break; | ||
|
@@ -156,12 +156,12 @@ void ag_deserialize_extended_type(char *base_addr, uint32 offset, | |
{ | ||
case AGT_HEADER_INTEGER: | ||
result->type = AGTV_INTEGER; | ||
result->val.int_value = *((int64 *)(base + AGT_HEADER_SIZE)); | ||
memcpy(&result->val.int_value, base + AGT_HEADER_SIZE, sizeof(int64)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see why this is necessary, maybe it is just me, could you please elaborate? |
||
break; | ||
|
||
case AGT_HEADER_FLOAT: | ||
result->type = AGTV_FLOAT; | ||
result->val.float_value = *((float8 *)(base + AGT_HEADER_SIZE)); | ||
memcpy(&result->val.float_value, base + AGT_HEADER_SIZE, sizeof(float8)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see why this is necessary, maybe it is just me, could you please elaborate? |
||
break; | ||
|
||
case AGT_HEADER_VERTEX: | ||
|
@@ -195,7 +195,7 @@ static void ag_deserialize_composite(char *base, enum agtype_value_type type, | |
//offset container by the extended type header | ||
char *container_base = base + AGT_HEADER_SIZE; | ||
|
||
r = palloc(sizeof(agtype_value)); | ||
r = palloc0(sizeof(agtype_value)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While it is generally good form to pre-initialize to zero, is it really necessary if the routine that uses it, sets it up properly? In the case of these iterator functions, which are generally slow, it takes up additional cpu cycles. So, I'm not sure this is necessary. Can you justify adding this? |
||
|
||
it = agtype_iterator_init((agtype_container *)container_base); | ||
while ((tok = agtype_iterator_next(&it, r, true)) != WAGT_DONE) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -460,7 +460,7 @@ agtype_value *find_agtype_value_from_container(agtype_container *container, | |
return NULL; | ||
} | ||
|
||
result = palloc(sizeof(agtype_value)); | ||
result = palloc0(sizeof(agtype_value)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to the above palloc0 comment. I'm not opposed to adding this in, I'm just not sure that it is necessary. |
||
|
||
if ((flags & AGT_FARRAY) && AGTYPE_CONTAINER_IS_ARRAY(container)) | ||
{ | ||
|
@@ -554,7 +554,7 @@ agtype_value *get_ith_agtype_value_from_container(agtype_container *container, | |
if (i >= nelements) | ||
return NULL; | ||
|
||
result = palloc(sizeof(agtype_value)); | ||
result = palloc0(sizeof(agtype_value)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to the above palloc0 comment. I'm not opposed to adding this in, I'm just not sure that it is necessary. |
||
|
||
fill_agtype_value(container, i, base_addr, get_agtype_offset(container, i), | ||
result); | ||
|
@@ -716,7 +716,7 @@ static agtype_value *push_agtype_value_scalar(agtype_parse_state **pstate, | |
(*pstate)->size = 4; | ||
} | ||
(*pstate)->cont_val.val.array.elems = | ||
palloc(sizeof(agtype_value) * (*pstate)->size); | ||
palloc0(sizeof(agtype_value) * (*pstate)->size); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to the above palloc0 comment. I'm not opposed to adding this in, I'm just not sure that it is necessary. |
||
(*pstate)->last_updated_value = NULL; | ||
break; | ||
case WAGT_BEGIN_OBJECT: | ||
|
@@ -727,7 +727,7 @@ static agtype_value *push_agtype_value_scalar(agtype_parse_state **pstate, | |
(*pstate)->cont_val.val.object.num_pairs = 0; | ||
(*pstate)->size = 4; | ||
(*pstate)->cont_val.val.object.pairs = | ||
palloc(sizeof(agtype_pair) * (*pstate)->size); | ||
palloc0(sizeof(agtype_pair) * (*pstate)->size); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to the above palloc0 comment. I'm not opposed to adding this in, I'm just not sure that it is necessary. |
||
(*pstate)->last_updated_value = NULL; | ||
break; | ||
case WAGT_KEY: | ||
|
@@ -784,7 +784,7 @@ static agtype_value *push_agtype_value_scalar(agtype_parse_state **pstate, | |
*/ | ||
static agtype_parse_state *push_state(agtype_parse_state **pstate) | ||
{ | ||
agtype_parse_state *ns = palloc(sizeof(agtype_parse_state)); | ||
agtype_parse_state *ns = palloc0(sizeof(agtype_parse_state)); | ||
|
||
ns->next = *pstate; | ||
return ns; | ||
|
@@ -1306,7 +1306,7 @@ bool agtype_deep_contains(agtype_iterator **val, agtype_iterator **m_contained) | |
uint32 j = 0; | ||
|
||
/* Make room for all possible values */ | ||
lhs_conts = palloc(sizeof(agtype_value) * num_lhs_elems); | ||
lhs_conts = palloc0(sizeof(agtype_value) * num_lhs_elems); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to the above palloc0 comment. I'm not opposed to adding this in, I'm just not sure that it is necessary. |
||
|
||
for (i = 0; i < num_lhs_elems; i++) | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -160,7 +160,7 @@ int create_edges_from_csv_file(char *file_path, | |
struct csv_parser p; | ||
char buf[1024]; | ||
size_t bytes_read; | ||
unsigned char options = 0; | ||
unsigned char options = CSV_APPEND_NULL; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please elaborate why. This is not dismissing it, but inquiring why. |
||
csv_edge_reader cr; | ||
|
||
if (csv_init(&p, options) != 0) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -194,7 +194,7 @@ int create_labels_from_csv_file(char *file_path, | |
struct csv_parser p; | ||
char buf[1024]; | ||
size_t bytes_read; | ||
unsigned char options = 0; | ||
unsigned char options = CSV_APPEND_NULL; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please elaborate why. This is not dismissing it, but inquiring why. |
||
csv_vertex_reader cr; | ||
|
||
if (csv_init(&p, options) != 0) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While it is generally good form to pre-initialize to zero, is it really necessary if the routine that uses it, sets it up properly? In the case of these iterator functions, which are generally slow, it takes up additional cpu cycles. So, I'm not sure this is necessary. Can you justify adding this?