Skip to content
Browse files

Make sure codec is created before file writer is initialized fully

  • Loading branch information...
1 parent e9db551 commit d5757f05fa15137b4d39de6d2b2eed7d978b306d Lucas Martin-King committed with lmartinking
Showing with 6 additions and 7 deletions.
  1. +6 −7 lang/c/src/datafile.c
View
13 lang/c/src/datafile.c
@@ -153,13 +153,6 @@ avro_file_writer_create(const char *path, avro_schema_t schema,
avro_set_error("Cannot allocate new file writer");
return ENOMEM;
}
- rval = file_writer_create(path, schema, w);
- if (rval) {
- avro_freet(struct avro_file_writer_t_, w);
- return rval;
- }
- *writer = w;
-
w->codec = avro_new(struct avro_codec_t_);
if (!w->codec) {
avro_set_error("Cannot allocate new codec");
@@ -170,6 +163,12 @@ avro_file_writer_create(const char *path, avro_schema_t schema,
avro_freet(struct avro_codec_t_, w->codec);
return rval;
}
+ rval = file_writer_create(path, schema, w);
+ if (rval) {
+ avro_freet(struct avro_file_writer_t_, w);
+ return rval;
+ }
+ *writer = w;
return 0;
}

0 comments on commit d5757f0

Please sign in to comment.
Something went wrong with that request. Please try again.