Changeset 7013eb9


Ignore:
Timestamp:
Jan 5, 2011, 1:35:52 PM (11 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
release-1.7
Children:
4976e93
Parents:
2e5b2f9
git-author:
David Benjamin <davidben@mit.edu> (01/02/11 19:37:28)
git-committer:
David Benjamin <davidben@mit.edu> (01/05/11 13:35:52)
Message:
If a smartfilter fails to parse, handle the error

Otherwise we segfault. Of course, we should always succeed in creating a
filter, but we sometimes don't because of quoting bugs.
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • commands.c

    rb31f1c9 r7013eb9  
    22912291  }
    22922292  filtname = owl_function_classinstfilt(argv[1], NULL, owl_global_is_narrow_related(&g));
    2293   owl_function_change_currentview_filter(filtname);
    2294   owl_free(filtname);
     2293  if (filtname) {
     2294    owl_function_change_currentview_filter(filtname);
     2295    owl_free(filtname);
     2296  }
    22952297  return NULL;
    22962298}
     
    23042306  }
    23052307  filtname=owl_function_zuserfilt(argv[1]);
    2306   owl_function_change_currentview_filter(filtname);
    2307   owl_free(filtname);
     2308  if (filtname) {
     2309    owl_function_change_currentview_filter(filtname);
     2310    owl_free(filtname);
     2311  }
    23082312  return NULL;
    23092313}
     
    23952399char *owl_command_colorclass(int argc, const char *const *argv, const char *buff)
    23962400{
    2397   const char *filtname;
     2401  char *filtname;
    23982402 
    23992403  if (argc < 3 || argc > 4) {
     
    24032407
    24042408  filtname=owl_function_classinstfilt(argv[1], NULL, owl_global_is_narrow_related(&g));
    2405   (void) owl_function_color_filter(filtname, argv[2], (argc == 4 ? argv[3] : NULL));
     2409  if (filtname) {
     2410    (void) owl_function_color_filter(filtname, argv[2], (argc == 4 ? argv[3] : NULL));
     2411    owl_free(filtname);
     2412  }
    24062413  return NULL;
    24072414}
  • functions.c

    rf85278b r7013eb9  
    22802280/* Create a filter for a class, instance if one doesn't exist.  If
    22812281 * instance is NULL then catch all messgaes in the class.  Returns the
    2282  * name of the filter, which the caller must free.
     2282 * name of the filter or null.  The caller must free this name.
    22832283 * If 'related' is nonzero, encompass unclasses and .d classes as well.
    22842284 */
     
    23482348
    23492349  f = owl_filter_new_fromstring(filtname, argbuff);
     2350  owl_free(argbuff);
     2351  if (f == NULL) {
     2352    /* Couldn't make a filter for some reason. Return NULL. */
     2353    owl_function_error("Error creating filter '%s'", filtname);
     2354    owl_free(filtname);
     2355    filtname = NULL;
     2356    goto done;
     2357  }
    23502358
    23512359  /* add it to the global list */
    23522360  owl_global_add_filter(&g, f);
    23532361
    2354   owl_free(argbuff);
    23552362done:
    23562363  owl_free(class);
     
    23902397      "recipient ^%1$s$ ) ) ) or ( ( class ^login$ ) and ( sender ^%1$s$ ) )",
    23912398      esclonguser);
     2399  owl_free(esclonguser);
    23922400
    23932401  f = owl_filter_new_fromstring(filtname, argbuff);
     2402  owl_free(argbuff);
     2403
     2404  if (f == NULL) {
     2405    /* Couldn't make a filter for some reason. Return NULL. */
     2406    owl_function_error("Error creating filter '%s'", filtname);
     2407    owl_free(filtname);
     2408    return NULL;
     2409  }
    23942410
    23952411  /* add it to the global list */
    23962412  owl_global_add_filter(&g, f);
    2397 
    2398   /* free stuff */
    2399   owl_free(argbuff);
    2400   owl_free(esclonguser);
    24012413
    24022414  return(filtname);
     
    24302442      "( sender ^%2$s$ and recipient ^%1$s$ ) ) )",
    24312443      escuser, owl_global_get_aim_screenname_for_filters(&g));
     2444  owl_free(escuser);
    24322445
    24332446  f = owl_filter_new_fromstring(filtname, argbuff);
     2447  owl_free(argbuff);
     2448
     2449  if (f == NULL) {
     2450    owl_function_error("Error creating filter '%s'", filtname);
     2451    owl_free(filtname);
     2452    return NULL;
     2453  }
    24342454
    24352455  /* add it to the global list */
    24362456  owl_global_add_filter(&g, f);
    2437 
    2438   /* free stuff */
    2439   owl_free(argbuff);
    2440   owl_free(escuser);
    24412457
    24422458  return(filtname);
     
    24602476
    24612477  argbuff = owl_sprintf("type ^%s$", esctype);
     2478  owl_free(esctype);
    24622479
    24632480  f = owl_filter_new_fromstring(filtname, argbuff);
     2481  owl_free(argbuff);
     2482
     2483  if (f == NULL) {
     2484    owl_function_error("Error creating filter '%s'", filtname);
     2485    owl_free(filtname);
     2486    return NULL;
     2487  }
    24642488
    24652489  /* add it to the global list */
    24662490  owl_global_add_filter(&g, f);
    2467 
    2468   /* free stuff */
    2469   owl_free(argbuff);
    2470   owl_free(esctype);
    24712491
    24722492  return filtname;
     
    25202540  f = owl_filter_new_fromstring(filtname, buf->str);
    25212541  g_string_free(buf, true);
     2542
     2543  if (f == NULL) {
     2544    owl_function_error("Error creating filter '%s'", filtname);
     2545    owl_free(filtname);
     2546    return NULL;
     2547  }
    25222548
    25232549  owl_global_add_filter(&g, f);
Note: See TracChangeset for help on using the changeset viewer.