commit 7756c6de747ddfe245279d4b0a4848476add2103
parent 541f7eb3c95001587904b8521ca11dc610047fa1
Author: Christian Grothoff <christian@grothoff.org>
Date: Sat, 14 Aug 2010 20:22:00 +0000
avoid malloc and strlen
Diffstat:
1 file changed, 14 insertions(+), 18 deletions(-)
diff --git a/src/plugins/dvi_extractor.c b/src/plugins/dvi_extractor.c
@@ -188,24 +188,20 @@ EXTRACTOR_dvi_extract (const unsigned char *data,
"application/x-dvi",
strlen ("application/x-dvi") +1))
return 1;
- comment = malloc (klen + 1);
- if (comment != NULL)
- {
- comment[klen] = '\0';
- memcpy (comment, &data[15], klen);
- if (0 != proc (proc_cls,
- "dvi",
- EXTRACTOR_METATYPE_COMMENT,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- comment,
- strlen (comment) +1))
- {
- free (comment);
- return 1;
- }
- free (comment);
- }
+ {
+ char comment[klen + 1];
+
+ comment[klen] = '\0';
+ memcpy (comment, &data[15], klen);
+ if (0 != proc (proc_cls,
+ "dvi",
+ EXTRACTOR_METATYPE_COMMENT,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ comment,
+ klen +1))
+ return 1;
+ }
/* try to find PDF/ps special */
pos = opos;
while (pos < size - 100)