Re: [PATCH v3 13/15] git_config_set: make use of the config parser's event stream
From: Jeff King <hidden>
Date: 2018-05-08 13:42:53
From: Jeff King <hidden>
Date: 2018-05-08 13:42:53
On Mon, Apr 09, 2018 at 10:32:20AM +0200, Johannes Schindelin wrote:
+static int store_aux_event(enum config_event_t type,
+ size_t begin, size_t end, void *data)
+{
+ struct config_store_data *store = data;
+
+ ALLOC_GROW(store->parsed, store->parsed_nr + 1, store->parsed_alloc);
+ store->parsed[store->parsed_nr].begin = begin;
+ store->parsed[store->parsed_nr].end = end;
+ store->parsed[store->parsed_nr].type = type;
+ store->parsed_nr++;
+
+ if (type == CONFIG_EVENT_SECTION) {
+ if (cf->var.len < 2 || cf->var.buf[cf->var.len - 1] != '.')
+ BUG("Invalid section name '%s'", cf->var.buf);I triggered this BUG today while playing around. Here's a minimal reproduction: echo '[broken' >config git config --file=config a.b c I'm not sure if it should simply be a die() and not a BUG(), since it depends on the input. Or if it is a BUG and we expected an earlier part of the code (like the event generator) to catch this broken case before we get to this function. -Peff