Changeset 215b8d5 for zwrite.c


Ignore:
Timestamp:
Sep 30, 2011, 11:47:08 PM (13 years ago)
Author:
David Benjamin <davidben@mit.edu>
Children:
9579509
Parents:
f89cc6f
git-author:
David Benjamin <davidben@mit.edu> (09/30/11 23:38:07)
git-committer:
David Benjamin <davidben@mit.edu> (09/30/11 23:47:08)
Message:
Cleanup in owl_zwrite_create on error cases

Before, the caller was required to cleanup, even on error. This is kind
of weird. In particular, owl_zwrite_create_and_send_from_line forgot to
so there was a small leak in there.

Also with the previous set of commits it's now possible to error from
owl_zwrite_create_from_line before the owl_zwrite is initialized, which
means that owl_zwrite_new_from_line on misquoted strings explodes. Oops.
Although I don't think this is actually possible to trigger.

Also be consistent about whether rv != 0 or rv < 0 is the error
condition. Barring any actual arguments one or another, I'm going to
arbitrary declare it's the former since that function doesn't really
have a useful number to return.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • zwrite.c

    r6329cd5 r215b8d5  
    44{
    55  owl_zwrite *z = g_new(owl_zwrite, 1);
    6   if (owl_zwrite_create_from_line(z, line) < 0) {
    7     owl_zwrite_delete(z);
     6  if (owl_zwrite_create_from_line(z, line) != 0) {
     7    g_free(z);
    88    return NULL;
    99  }
     
    1414{
    1515  owl_zwrite *z = g_new(owl_zwrite, 1);
    16   if (owl_zwrite_create(z, argc, argv) < 0) {
    17     owl_zwrite_delete(z);
     16  if (owl_zwrite_create(z, argc, argv) != 0) {
     17    g_free(z);
    1818    return NULL;
    1919  }
     
    135135
    136136  if (badargs) {
     137    owl_zwrite_cleanup(z);
    137138    return(-1);
    138139  }
     
    142143      z->recips->len == 0) {
    143144    owl_function_error("You must specify a recipient for zwrite");
     145    owl_zwrite_cleanup(z);
    144146    return(-1);
    145147  }
     
    267269  owl_zwrite z;
    268270  int rv;
    269   rv=owl_zwrite_create_from_line(&z, cmd);
    270   if (rv) return(rv);
     271  rv = owl_zwrite_create_from_line(&z, cmd);
     272  if (rv != 0) return rv;
    271273  if (!owl_zwrite_is_message_set(&z)) {
    272274    owl_zwrite_set_message(&z, msg);
Note: See TracChangeset for help on using the changeset viewer.