Nmap Development mailing list archives
[PATCH] Use assert() instead of if(...) abort() in snprintf.c
From: Kris Katterjohn <kjak () ispwest com>
Date: Fri, 22 Sep 2006 19:51:50 -0500
The attached patch uses assert() instead of if () abort() in nbase/snprintf.c It's a diff against 4.20ALPHA7 Thanks, Kris Katterjohn
--- x/nbase/snprintf.c 2005-04-14 20:23:49.000000000 -0500
+++ y/nbase/snprintf.c 2006-09-22 19:46:30.000000000 -0500
@@ -58,6 +58,7 @@ static const char rcsid[] =
#include <string.h>
#include <ctype.h>
#include <sys/types.h>
+#include <assert.h>
#if HAVE_LIBIBERTY_H
#include <libiberty.h>
@@ -496,12 +497,10 @@ snprintf (char *str, size_t sz, const ch
char *tmp;
tmp = malloc (sz);
- if (tmp == NULL)
- abort ();
+ assert(tmp);
ret2 = vsprintf (tmp, format, args);
- if (ret != ret2 || strcmp(str, tmp))
- abort ();
+ assert(ret == ret2 && !strcmp(str, tmp));
free (tmp);
}
#endif
@@ -577,12 +576,10 @@ asprintf (char **ret, const char *format
int ret2;
char *tmp;
tmp = malloc (val + 1);
- if (tmp == NULL)
- abort ();
+ assert(tmp);
ret2 = vsprintf (tmp, format, args);
- if (val != ret2 || strcmp(*ret, tmp))
- abort ();
+ assert(val == ret2 && !strcmp(*ret, tmp));
free (tmp);
}
#endif
@@ -607,12 +604,10 @@ asnprintf (char **ret, size_t max_sz, co
int ret2;
char *tmp;
tmp = malloc (val + 1);
- if (tmp == NULL)
- abort ();
+ assert(tmp);
ret2 = vsprintf (tmp, format, args);
- if (val != ret2 || strcmp(*ret, tmp))
- abort ();
+ assert(val == ret2 && !strcmp(*ret, tmp));
free (tmp);
}
#endif
_______________________________________________ Sent through the nmap-dev mailing list http://cgi.insecure.org/mailman/listinfo/nmap-dev Archived at http://SecLists.Org
Current thread:
- [PATCH] Use assert() instead of if(...) abort() in snprintf.c Kris Katterjohn (Sep 22)
