git-svn: trunk@3875
Török Edvin authored on 2008/06/03 00:43:46... | ... |
@@ -1,3 +1,8 @@ |
1 |
+Mon Jun 2 17:59:15 EEST 2008 (edwin) |
|
2 |
+------------------------------------- |
|
3 |
+ * libclamav/hashtab.[ch], scanners.c: avoid using C99 flexible array members |
|
4 |
+ (bb #1039) |
|
5 |
+ |
|
1 | 6 |
Mon Jun 2 14:57:31 CEST 2008 (tk) |
2 | 7 |
---------------------------------- |
3 | 8 |
* freshclam: in interactive mode EXIT_n can be passed to --on-*-execute |
... | ... |
@@ -562,9 +562,14 @@ ssize_t hashset_toarray(const struct hashset* hs, uint32_t** array) |
562 | 562 |
struct uniq *uniq_init(uint32_t count) { |
563 | 563 |
struct uniq *U; |
564 | 564 |
if(!count) return NULL; |
565 |
- count = count <= 256 ? 256 : count + (count*20/100); |
|
566 |
- U = (struct uniqueid *)cli_calloc(1, sizeof(U)+sizeof(uint32_t)*count); |
|
565 |
+ count = count <= 256 ? 256 : count + (count*20/100); |
|
566 |
+ U = cli_malloc(sizeof(*U)); |
|
567 | 567 |
if(!U) return NULL; |
568 |
+ U->uniques = cli_calloc(count, sizeof(uint32_t)); |
|
569 |
+ if(!U->uniques) { |
|
570 |
+ free(U); |
|
571 |
+ return NULL; |
|
572 |
+ } |
|
568 | 573 |
U->count = count; |
569 | 574 |
return U; |
570 | 575 |
} |
... | ... |
@@ -109,11 +109,11 @@ ssize_t hashset_toarray(const struct hashset* hs, uint32_t** array); |
109 | 109 |
/* A basic storage for unique IDs */ |
110 | 110 |
struct uniq { |
111 | 111 |
uint32_t count; |
112 |
- uint32_t uniques[]; |
|
112 |
+ uint32_t *uniques; |
|
113 | 113 |
}; |
114 | 114 |
|
115 | 115 |
struct uniq *uniq_init(uint32_t); |
116 |
-#define uniq_free(X) free(X); |
|
116 |
+#define uniq_free(X) do { if(X) free(X->uniques); free(X); } while (0) |
|
117 | 117 |
uint32_t uniq_add(struct uniq *, const char *, uint32_t, uint32_t *); |
118 | 118 |
uint32_t uniq_get(struct uniq *, const char *, uint32_t, uint32_t *); |
119 | 119 |
|
... | ... |
@@ -1124,7 +1124,7 @@ static int cli_scanole2(int desc, cli_ctx *ctx) |
1124 | 1124 |
ctx->recursion++; |
1125 | 1125 |
|
1126 | 1126 |
ret = cli_vba_scandir(dir, ctx, vba); |
1127 |
- free(vba); |
|
1127 |
+ uniq_free(vba); |
|
1128 | 1128 |
if(ret != CL_VIRUS) |
1129 | 1129 |
if(cli_scandir(dir, ctx, 0) == CL_VIRUS) |
1130 | 1130 |
ret = CL_VIRUS; |