Copilot commented on code in PR #3527:
URL: https://github.com/apache/avro/pull/3527#discussion_r2464951484
##########
lang/c/tests/test_avro_data.c:
##########
@@ -214,6 +216,34 @@ static int test_bytes(void)
return 0;
}
+static int test_empty_bytes(void)
+{
+ char bytes[] = { };
+ avro_schema_t writer_schema = avro_schema_bytes();
+ avro_datum_t datum;
+ avro_datum_t expected_datum;
+
+ datum = avro_givebytes(bytes, sizeof(bytes), NULL);
+ write_read_check(writer_schema, datum, NULL, NULL, "bytes");
+ test_json(datum, "\"\"");
+ avro_datum_decref(datum);
+ avro_schema_decref(writer_schema);
+
+ datum = avro_givebytes(NULL, 0, NULL);
+ avro_givebytes_set(datum, bytes, sizeof(bytes), NULL);
+ expected_datum = avro_givebytes(bytes, sizeof(bytes), NULL);
+ if (!avro_datum_equal(datum, expected_datum)) {
+ fprintf(stderr,
+ "Expected equal bytes instances.\n");
+ exit(EXIT_FAILURE);
+ }
+ avro_datum_decref(datum);
+ avro_datum_decref(expected_datum);
+
+ avro_schema_decref(writer_schema);
Review Comment:
Double free: `writer_schema` is already decremented at line 230, so this
second decrement at line 243 will cause a use-after-free error.
```suggestion
```
##########
lang/c/tests/test_avro_data.c:
##########
@@ -214,6 +216,34 @@ static int test_bytes(void)
return 0;
}
+static int test_empty_bytes(void)
+{
+ char bytes[] = { };
Review Comment:
Empty array initializer `{ }` is a GNU extension and not standard C.
Consider using `char *bytes = NULL;` or `char bytes[1];` for better portability
across compilers.
```suggestion
char *bytes = NULL;
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]