From: Matt Kraai Date: Tue, 30 Oct 2012 18:43:51 GMT Subject: Re: [PATCH] parse_dirstat_params(): use string_list to split comma-separated string Message-ID: In-Reply-To: <1351443054-10472-1-git-send-email-mhagger@alum.mit.edu> Michael Haggerty alum.mit.edu> writes: ... > -static int parse_dirstat_params(struct diff_options *options, const char ... > +static int parse_dirstat_params(struct diff_options *options, const char ... > struct strbuf *errmsg) > { > - const char *p = params; > - int p_len, ret = 0; > + char *params_copy = xstrdup(params_string); > + struct string_list params = STRING_LIST_INIT_NODUP; > + int ret = 0; > + int i; > > - while (*p) { > - p_len = strchrnul(p, ',') - p; > - if (!memcmp(p, "changes", p_len)) { > + if (*params_copy) params_copy is set to the value returned by xstrdup, which cannot be NULL. This check can be removed and if params_string can be NULL, it should be checked before being passed to xstrdup.