aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/html_extractor.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/html_extractor.c')
-rw-r--r--src/plugins/html_extractor.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/src/plugins/html_extractor.c b/src/plugins/html_extractor.c
index 243cf16..f7e367a 100644
--- a/src/plugins/html_extractor.c
+++ b/src/plugins/html_extractor.c
@@ -205,6 +205,8 @@ findInTags (TagInfo * t,
205 if (pstart != NULL) 205 if (pstart != NULL)
206 { 206 {
207 char *ret = malloc (pend - pstart + 1); 207 char *ret = malloc (pend - pstart + 1);
208 if (ret == NULL)
209 return NULL;
208 memcpy (ret, pstart, pend - pstart); 210 memcpy (ret, pstart, pend - pstart);
209 ret[pend - pstart] = '\0'; 211 ret[pend - pstart] = '\0';
210 return ret; 212 return ret;
@@ -290,6 +292,8 @@ EXTRACTOR_html_extract (const char *data,
290 tag.tagStart, tag.tagEnd - tag.tagStart))) 292 tag.tagStart, tag.tagEnd - tag.tagStart)))
291 { 293 {
292 t = malloc (sizeof (TagInfo)); 294 t = malloc (sizeof (TagInfo));
295 if (t == NULL)
296 return 0;
293 *t = tag; 297 *t = tag;
294 t->next = tags; 298 t->next = tags;
295 tags = t; 299 tags = t;
@@ -357,7 +361,8 @@ EXTRACTOR_html_extract (const char *data,
357 free (xtmp); 361 free (xtmp);
358 } 362 }
359 } 363 }
360 free (tmp); 364 if (tmp != NULL)
365 free (tmp);
361 i++; 366 i++;
362 } 367 }
363 while (tags != NULL) 368 while (tags != NULL)
@@ -369,16 +374,19 @@ EXTRACTOR_html_extract (const char *data,
369 if (charset == NULL) 374 if (charset == NULL)
370 { 375 {
371 xtmp = malloc (t->dataEnd - t->dataStart + 1); 376 xtmp = malloc (t->dataEnd - t->dataStart + 1);
372 memcpy (xtmp, t->dataStart, t->dataEnd - t->dataStart); 377 if (xtmp != NULL)
373 xtmp[t->dataEnd - t->dataStart] = '\0'; 378 {
374 ret = proc (proc_cls, 379 memcpy (xtmp, t->dataStart, t->dataEnd - t->dataStart);
375 "html", 380 xtmp[t->dataEnd - t->dataStart] = '\0';
376 EXTRACTOR_METATYPE_TITLE, 381 ret = proc (proc_cls,
377 EXTRACTOR_METAFORMAT_C_STRING, 382 "html",
378 "text/plain", 383 EXTRACTOR_METATYPE_TITLE,
379 xtmp, 384 EXTRACTOR_METAFORMAT_C_STRING,
380 strlen (xtmp) + 1); 385 "text/plain",
381 free (xtmp); 386 xtmp,
387 strlen (xtmp) + 1);
388 free (xtmp);
389 }
382 } 390 }
383 else 391 else
384 { 392 {