Changeset e6a4dd5 for filterelement.c


Ignore:
Timestamp:
Apr 2, 2009, 1:23:14 AM (12 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, debian, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
3071c69
Parents:
d9bfc82
Message:
Propagate regex compile failures out of filter creation.

Make calls to owl_filter_init_fromstring fail if the filter includes an
illegal regex (e.g. an initial *), by having owl_filterelement_create_re
return an error code which propagates up.

This fixes an issue where a command like 'unpunt class *' would segfault
because it succeeds in creating the invalid filter, but then fails to
print it successfully.

fixes: #70
File:
1 edited

Legend:

Unmodified
Added
Removed
  • filterelement.c

    rf446454 re6a4dd5  
    213213}
    214214
    215 void owl_filterelement_create_re(owl_filterelement *fe, char *field, char *re)
     215int owl_filterelement_create_re(owl_filterelement *fe, char *field, char *re)
    216216{
    217217  owl_filterelement_create(fe);
    218218  fe->field=owl_strdup(field);
    219   owl_regex_create(&(fe->re), re);
     219  if(owl_regex_create(&(fe->re), re)) {
     220    free(fe->field);
     221    fe->field = NULL;
     222    return (-1);
     223  }
    220224  fe->match_message = owl_filterelement_match_re;
    221225  fe->print_elt = owl_filterelement_print_re;
     226  return 0;
    222227}
    223228
Note: See TracChangeset for help on using the changeset viewer.