Fix warnings due to missing includes. Check that comment != NULL if len > 0, avoid _zip_memdup with size 0. --HG-- branch : HEAD
diff --git a/lib/zip_set_archive_comment.c b/lib/zip_set_archive_comment.c index 17fa344..86bb991 100644 --- a/lib/zip_set_archive_comment.c +++ b/lib/zip_set_archive_comment.c
@@ -1,5 +1,5 @@ /* - $NiH: zip_set_archive_comment.c,v 1.1 2006/04/23 00:40:48 wiz Exp $ + $NiH: zip_set_archive_comment.c,v 1.2 2006/04/23 15:26:30 dillo Exp $ zip_set_archive_comment.c -- set archive comment Copyright (C) 2006 Dieter Baron and Thomas Klausner @@ -35,6 +35,8 @@ +#include <stdlib.h> + #include "zip.h" #include "zipint.h" @@ -45,13 +47,18 @@ { char *tmpcom; - if (len < 0 || len > MAXCOMLEN) { + if (len < 0 || len > MAXCOMLEN + || (len > 0 && comment == NULL)) { _zip_error_set(&za->error, ZIP_ER_INVAL, 0); return -1; } - if ((tmpcom=(char *)_zip_memdup(comment, len, &za->error)) == NULL) - return -1; + if (len > 0) { + if ((tmpcom=(char *)_zip_memdup(comment, len, &za->error)) == NULL) + return -1; + } + else + tmpcom = NULL; free(za->ch_comment); za->ch_comment = tmpcom;