summaryrefslogtreecommitdiff
path: root/src/tr.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1996-10-31 23:49:42 +0000
committerJim Meyering <jim@meyering.net>1996-10-31 23:49:42 +0000
commit0a1ac00ad6b0e5b82ea70eca121c92bdc27677fd (patch)
tree9e73b7f86d2429c4d93e8f3b737f55f4a9b81160 /src/tr.c
parente5947e883ec53b43220dcff9f1906ad80e35be82 (diff)
downloadcoreutils-0a1ac00ad6b0e5b82ea70eca121c92bdc27677fd.tar.xz
(es_free): New function.
(parse_str): Use it to plug small memory leak.
Diffstat (limited to 'src/tr.c')
-rw-r--r--src/tr.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/tr.c b/src/tr.c
index 95b1ad939..65868975d 100644
--- a/src/tr.c
+++ b/src/tr.c
@@ -479,6 +479,13 @@ is_char_class_member (enum Char_class char_class, unsigned int c)
return result;
}
+static void
+es_free (struct E_string *es)
+{
+ free (es->s);
+ free (es->escaped);
+}
+
/* Perform the first pass over each range-spec argument S, converting all
\c and \ddd escapes to their one-byte representations. The conversion
is done in-place, so S must point to writable storage. If an invalid
@@ -1441,12 +1448,13 @@ static int
parse_str (const unsigned char *s, struct Spec_list *spec_list)
{
struct E_string es;
+ int fail;
- if (unquote (s, &es))
- return 1;
- if (build_spec_list (&es, spec_list))
- return 1;
- return 0;
+ fail = unquote (s, &es);
+ if (!fail)
+ fail = build_spec_list (&es, spec_list);
+ es_free (&es);
+ return fail;
}
/* Given two specification lists, S1 and S2, and assuming that