diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-02-24 17:05:52 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-02-24 17:05:52 +0000 |
commit | 629563b5d7baee9a2008cd102924be6d55321bb7 (patch) | |
tree | cda7b6703ac5561224d46515bec491148e335c09 | |
parent | 5276402f2cdf39f8963243d7f54bf7f8c32ffd29 (diff) | |
download | busybox-w32-629563b5d7baee9a2008cd102924be6d55321bb7.tar.gz busybox-w32-629563b5d7baee9a2008cd102924be6d55321bb7.tar.bz2 busybox-w32-629563b5d7baee9a2008cd102924be6d55321bb7.zip |
awk: fix memory leak (can affect large file processing)
-rw-r--r-- | editors/awk.c | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/editors/awk.c b/editors/awk.c index 9af6ecc5b..d0b03c373 100644 --- a/editors/awk.c +++ b/editors/awk.c | |||
@@ -12,34 +12,34 @@ | |||
12 | #include <math.h> | 12 | #include <math.h> |
13 | 13 | ||
14 | 14 | ||
15 | #define MAXVARFMT 240 | 15 | #define MAXVARFMT 240 |
16 | #define MINNVBLOCK 64 | 16 | #define MINNVBLOCK 64 |
17 | 17 | ||
18 | /* variable flags */ | 18 | /* variable flags */ |
19 | #define VF_NUMBER 0x0001 /* 1 = primary type is number */ | 19 | #define VF_NUMBER 0x0001 /* 1 = primary type is number */ |
20 | #define VF_ARRAY 0x0002 /* 1 = it's an array */ | 20 | #define VF_ARRAY 0x0002 /* 1 = it's an array */ |
21 | 21 | ||
22 | #define VF_CACHED 0x0100 /* 1 = num/str value has cached str/num eq */ | 22 | #define VF_CACHED 0x0100 /* 1 = num/str value has cached str/num eq */ |
23 | #define VF_USER 0x0200 /* 1 = user input (may be numeric string) */ | 23 | #define VF_USER 0x0200 /* 1 = user input (may be numeric string) */ |
24 | #define VF_SPECIAL 0x0400 /* 1 = requires extra handling when changed */ | 24 | #define VF_SPECIAL 0x0400 /* 1 = requires extra handling when changed */ |
25 | #define VF_WALK 0x0800 /* 1 = variable has alloc'd x.walker list */ | 25 | #define VF_WALK 0x0800 /* 1 = variable has alloc'd x.walker list */ |
26 | #define VF_FSTR 0x1000 /* 1 = string points to fstring buffer */ | 26 | #define VF_FSTR 0x1000 /* 1 = var::string points to fstring buffer */ |
27 | #define VF_CHILD 0x2000 /* 1 = function arg; x.parent points to source */ | 27 | #define VF_CHILD 0x2000 /* 1 = function arg; x.parent points to source */ |
28 | #define VF_DIRTY 0x4000 /* 1 = variable was set explicitly */ | 28 | #define VF_DIRTY 0x4000 /* 1 = variable was set explicitly */ |
29 | 29 | ||
30 | /* these flags are static, don't change them when value is changed */ | 30 | /* these flags are static, don't change them when value is changed */ |
31 | #define VF_DONTTOUCH (VF_ARRAY | VF_SPECIAL | VF_WALK | VF_CHILD | VF_DIRTY) | 31 | #define VF_DONTTOUCH (VF_ARRAY | VF_SPECIAL | VF_WALK | VF_CHILD | VF_DIRTY) |
32 | 32 | ||
33 | /* Variable */ | 33 | /* Variable */ |
34 | typedef struct var_s { | 34 | typedef struct var_s { |
35 | unsigned short type; /* flags */ | 35 | unsigned short type; /* flags */ |
36 | double number; | 36 | double number; |
37 | char *string; | 37 | char *string; |
38 | union { | 38 | union { |
39 | int aidx; /* func arg idx (for compilation stage) */ | 39 | int aidx; /* func arg idx (for compilation stage) */ |
40 | struct xhash_s *array; /* array ptr */ | 40 | struct xhash_s *array; /* array ptr */ |
41 | struct var_s *parent; /* for func args, ptr to actual parameter */ | 41 | struct var_s *parent; /* for func args, ptr to actual parameter */ |
42 | char **walker; /* list of array elements (for..in) */ | 42 | char **walker; /* list of array elements (for..in) */ |
43 | } x; | 43 | } x; |
44 | } var; | 44 | } var; |
45 | 45 | ||
@@ -740,7 +740,7 @@ static var *copyvar(var *dest, const var *src) | |||
740 | { | 740 | { |
741 | if (dest != src) { | 741 | if (dest != src) { |
742 | clrvar(dest); | 742 | clrvar(dest); |
743 | dest->type |= (src->type & ~VF_DONTTOUCH); | 743 | dest->type |= (src->type & ~(VF_DONTTOUCH | VF_FSTR)); |
744 | dest->number = src->number; | 744 | dest->number = src->number; |
745 | if (src->string) | 745 | if (src->string) |
746 | dest->string = xstrdup(src->string); | 746 | dest->string = xstrdup(src->string); |