[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r1221 - GNUnet/src/applications/fs/ecrs
From: |
durner |
Subject: |
[GNUnet-SVN] r1221 - GNUnet/src/applications/fs/ecrs |
Date: |
Sun, 3 Jul 2005 03:40:44 -0700 (PDT) |
Author: durner
Date: 2005-07-03 03:40:41 -0700 (Sun, 03 Jul 2005)
New Revision: 1221
Modified:
GNUnet/src/applications/fs/ecrs/uri.c
Log:
fix crashes if keywords are NULL
Modified: GNUnet/src/applications/fs/ecrs/uri.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/uri.c 2005-07-03 09:59:16 UTC (rev
1220)
+++ GNUnet/src/applications/fs/ecrs/uri.c 2005-07-03 10:40:41 UTC (rev
1221)
@@ -554,6 +554,7 @@
char * kd;
struct tm t;
time_t now;
+ unsigned int keywordCount;
GNUNET_ASSERT(uri->type == ksk);
time(&now);
@@ -565,22 +566,28 @@
ret = MALLOC(sizeof(URI));
ret->type = ksk;
- ret->data.ksk.keywordCount = 2 * uri->data.ksk.keywordCount;
- ret->data.ksk.keywords = MALLOC(sizeof(char*) * ret->data.ksk.keywordCount);
- for (i=0;i<uri->data.ksk.keywordCount;i++) {
- key = uri->data.ksk.keywords[i];
- ret->data.ksk.keywords[2*i]
- = STRDUP(key);
- kd = MALLOC(strlen(key) + 13);
- memset(kd, 0, strlen(key) + 13);
- strcpy(kd, key);
- strftime(&kd[strlen(key)],
- 13,
- "-%Y-%m-%d",
- &t);
- ret->data.ksk.keywords[2*i+1]
- = kd;
+ keywordCount = uri->data.ksk.keywordCount;
+ ret->data.ksk.keywordCount = 2 * keywordCount;
+ if (keywordCount) {
+ ret->data.ksk.keywords = MALLOC(sizeof(char*) * keywordCount);
+ for (i=0;i<keywordCount;i++) {
+ key = uri->data.ksk.keywords[i];
+ ret->data.ksk.keywords[2*i]
+ = key ? STRDUP(key) : STRDUP("");
+ kd = MALLOC(strlen(key) + 13);
+ memset(kd, 0, strlen(key) + 13);
+ strcpy(kd, key);
+ strftime(&kd[strlen(key)],
+ 13,
+ "-%Y-%m-%d",
+ &t);
+ ret->data.ksk.keywords[2*i+1]
+ = kd;
+ }
}
+ else
+ ret->data.ksk.keywords = NULL;
+
return ret;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r1221 - GNUnet/src/applications/fs/ecrs,
durner <=