Revision: 56607
http://sourceforge.net/p/brlcad/code/56607
Author: brlcad
Date: 2013-08-05 22:13:24 +0000 (Mon, 05 Aug 2013)
Log Message:
-----------
calling bu_free() after malloc() is wrong, but we should be calling bu_malloc()
so do that instead. added some basic input sanity checking.
Modified Paths:
--------------
brlcad/trunk/src/util/bwshrink.c
Modified: brlcad/trunk/src/util/bwshrink.c
===================================================================
--- brlcad/trunk/src/util/bwshrink.c 2013-08-05 22:03:28 UTC (rev 56606)
+++ brlcad/trunk/src/util/bwshrink.c 2013-08-05 22:13:24 UTC (rev 56607)
@@ -182,17 +182,18 @@
int t;
(void)parse_args(ac, av);
- if (isatty(fileno(stdin))) usage();
+ if (isatty(fileno(stdin)))
+ usage();
/* process stdin */
/* get buffer for image */
size = width * height;
- if ((buffer = (unsigned char *)malloc(width*height)) == (unsigned char
*)NULL) {
- fprintf(stderr, "%s: cannot allocate input buffer\n",
- progname);
- bu_free(buffer, "buffer alloc from malloc");
- bu_exit (-1, NULL);
+ if (size > 0) {
+ buffer = (unsigned char *)bu_malloc(size, "alloc buffer");
+ } else {
+ bu_log("ERROR: zero dimension image\n");
+ usage();
}
/* read in entire image */
@@ -200,7 +201,6 @@
/* do nothing */;
}
-
if (c < 0) {
perror (filename);
return -1;
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Get your SQL database under version control now!
Version control is standard for application code, but databases havent
caught up. So what steps can you take to put your SQL databases under
version control? Why should you start doing it? Read more to find out.
http://pubads.g.doubleclick.net/gampad/clk?id=49501711&iu=/4140/ostg.clktrk
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits