Skip to content

Commit

Permalink
Tidy up rd_kafka_new() conf freeing to make code clearer (#2478)
Browse files Browse the repository at this point in the history
  • Loading branch information
edenhill committed Aug 19, 2019
1 parent d8f24f9 commit 317e55d
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/rdkafka.c
Original file line number Diff line number Diff line change
Expand Up @@ -2219,15 +2219,6 @@ rd_kafka_t *rd_kafka_new (rd_kafka_type_t type, rd_kafka_conf_t *app_conf,
pthread_sigmask(SIG_SETMASK, &oldset, NULL);
#endif

/* Free user supplied conf's base pointer on success,
* but not the actual allocated fields since the struct
* will have been copied in its entirety above. */
if (app_conf)
rd_free(app_conf);
rd_kafka_set_last_error(0, 0);

rd_kafka_conf_warn(rk);

/* Wait for background threads to fully initialize so that
* the client instance is fully functional at the time it is
* returned from the constructor. */
Expand Down Expand Up @@ -2273,7 +2264,14 @@ rd_kafka_t *rd_kafka_new (rd_kafka_type_t type, rd_kafka_conf_t *app_conf,
/* Log warnings for deprecated configuration */
rd_kafka_conf_warn(rk);

return rk;
/* Free user supplied conf's base pointer on success,
* but not the actual allocated fields since the struct
* will have been copied in its entirety above. */
if (app_conf)
rd_free(app_conf);
rd_kafka_set_last_error(0, 0);

return rk;

fail:
/*
Expand Down

0 comments on commit 317e55d

Please sign in to comment.