You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@avro.apache.org by "github-advanced-security[bot] (via GitHub)" <gi...@apache.org> on 2025/05/27 12:21:42 UTC

Re: [PR] [AVRO-4137, C#]: SpecificWriter Enum Name Matching [avro]

github-advanced-security[bot] commented on code in PR #3388:
URL: https://github.com/apache/avro/pull/3388#discussion_r2109039210


##########
lang/csharp/src/apache/main/Specific/SpecificDatumWriter.cs:
##########
@@ -139,7 +139,7 @@
                     return obj is ISpecificRecord &&
                            ((obj as ISpecificRecord).Schema as RecordSchema).SchemaName.Equals((sc as RecordSchema).SchemaName);
                 case Schema.Type.Enumeration:
-                    return obj.GetType().IsEnum && (sc as EnumSchema).Symbols.Contains(obj.ToString());
+                    return obj.GetType().IsEnum && (sc as EnumSchema).Symbols.Contains(obj.ToString()) && sc.Name.Equals(obj.GetType().Name);

Review Comment:
   ## Dereferenced variable may be null
   
   Variable [obj](1) may be null at this access as suggested by [this](2) null check.
   Variable [obj](1) may be null at this access as suggested by [this](3) null check.
   
   [Show more details](https://github.com/apache/avro/security/code-scanning/3328)



##########
lang/csharp/src/apache/main/Specific/SpecificWriter.cs:
##########
@@ -209,7 +209,7 @@
                     return obj is ISpecificRecord &&
                            ((obj as ISpecificRecord).Schema as RecordSchema).SchemaName.Equals((sc as RecordSchema).SchemaName);
                 case Schema.Type.Enumeration:
-                    return obj.GetType().IsEnum && (sc as EnumSchema).Symbols.Contains(obj.ToString());
+                    return obj.GetType().IsEnum && (sc as EnumSchema).Symbols.Contains(obj.ToString()) && sc.Name.Equals(obj.GetType().Name);

Review Comment:
   ## Dereferenced variable may be null
   
   Variable [obj](1) may be null at this access as suggested by [this](2) null check.
   Variable [obj](1) may be null at this access as suggested by [this](3) null check.
   
   [Show more details](https://github.com/apache/avro/security/code-scanning/3329)



-- 
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: issues-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org