Mailing List Archive

r3760 - trunk/c_src/KinoSearch/Util
Author: creamyg
Date: 2008-08-25 06:17:49 -0700 (Mon, 25 Aug 2008)
New Revision: 3760

Modified:
trunk/c_src/KinoSearch/Util/Debug.c
Log:
Fix some edge case bugs in Debug.c.


Modified: trunk/c_src/KinoSearch/Util/Debug.c
===================================================================
--- trunk/c_src/KinoSearch/Util/Debug.c 2008-08-25 04:46:32 UTC (rev 3759)
+++ trunk/c_src/KinoSearch/Util/Debug.c 2008-08-25 13:17:49 UTC (rev 3760)
@@ -11,6 +11,7 @@
#include <stdarg.h>
#include <ctype.h>
#include <string.h>
+#include <stdlib.h>

static char env_cache_buf[256];
static char *env_cache = NULL;
@@ -59,8 +60,8 @@
else {
const char *test, *next;
const char *file = strrchr(path, '/');
- const int filename_len = strlen(file);
- const int funcname_len = strlen(func);
+ const int filename_len = file ? strlen(file) : 0;
+ const int funcname_len = func ? strlen(func) : 0;

/* Use just file name if given path. */
if (file) file++;
@@ -72,7 +73,7 @@

/* Skip whitespace. */
while (isspace(*test)) test++;
- if (test == env_cache_limit) return 0;
+ if (test >= env_cache_limit) return 0;

/* Find end of criteria or end of string. */
next = strchr(test, ',');


_______________________________________________
kinosearch-commits mailing list
kinosearch-commits@rectangular.com
http://www.rectangular.com/mailman/listinfo/kinosearch-commits