[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r1226 - GNUnet/src/applications/fs/ecrs
From: |
grothoff |
Subject: |
[GNUnet-SVN] r1226 - GNUnet/src/applications/fs/ecrs |
Date: |
Sun, 3 Jul 2005 12:29:59 -0700 (PDT) |
Author: grothoff
Date: 2005-07-03 12:29:56 -0700 (Sun, 03 Jul 2005)
New Revision: 1226
Modified:
GNUnet/src/applications/fs/ecrs/meta.c
GNUnet/src/applications/fs/ecrs/uri.c
Log:
fixing bug discovered by Nils
Modified: GNUnet/src/applications/fs/ecrs/meta.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/meta.c 2005-07-03 19:00:26 UTC (rev
1225)
+++ GNUnet/src/applications/fs/ecrs/meta.c 2005-07-03 19:29:56 UTC (rev
1226)
@@ -81,6 +81,7 @@
const char * data) {
int idx;
+ GNUNET_ASSERT(data != NULL);
for (idx=0;idx<md->itemCount;idx++) {
if ( (md->items[idx].type == type) &&
(0 == strcmp(md->items[idx].data,
Modified: GNUnet/src/applications/fs/ecrs/uri.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/uri.c 2005-07-03 19:00:26 UTC (rev
1225)
+++ GNUnet/src/applications/fs/ecrs/uri.c 2005-07-03 19:29:56 UTC (rev
1226)
@@ -85,8 +85,8 @@
#include "ecrs.h"
#include "gnunet_ecrs_lib.h"
+#define EXTRA_CHECKS YES
-
/**
* Generate a keyword URI.
* @return NULL on error (i.e. keywordCount == 0)
@@ -231,7 +231,7 @@
if (uri[i] == '+') {
ret++;
if (uri[i-1] == '+')
- return SYSERR; /* ++ not allowed */
+ return SYSERR; /* "++" not allowed */
}
}
iret = ret;
@@ -244,6 +244,7 @@
}
}
(*keywords)[--ret] = STRDUP(&dup[pos]);
+ GNUNET_ASSERT(ret == 0);
FREE(dup);
return iret;
}
@@ -390,12 +391,8 @@
int i;
GNUNET_ASSERT(uri != NULL);
if (uri->type == ksk) {
- for (i=0;i<uri->data.ksk.keywordCount;i++) {
- char *key = uri->data.ksk.keywords[i];
-
- if (key)
- FREE(key);
- }
+ for (i=0;i<uri->data.ksk.keywordCount;i++)
+ FREE(uri->data.ksk.keywords[i]);
GROW(uri->data.ksk.keywords,
uri->data.ksk.keywordCount,
0);
@@ -446,6 +443,14 @@
* Is this a keyword URI?
*/
int ECRS_isKeywordUri(const struct ECRS_URI * uri) {
+#if EXTRA_CHECKS
+ int i;
+
+ if (uri->type == ksk) {
+ for (i=uri->data.ksk.keywordCount-1;i>=0;i--)
+ GNUNET_ASSERT(uri->data.ksk.keywords[i] != NULL);
+ }
+#endif
return uri->type == ksk;
}
@@ -568,25 +573,25 @@
ret->type = ksk;
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;
+ if (keywordCount > 0) {
+ ret->data.ksk.keywords = MALLOC(sizeof(char*) * keywordCount * 2);
+ for (i=0;i<keywordCount;i++) {
+ key = uri->data.ksk.keywords[i];
+ GNUNET_ASSERT(key != NULL);
+ 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;
+ }
+ } else
+ ret->data.ksk.keywords = NULL;
return ret;
}
@@ -637,9 +642,11 @@
md->items[j].data)) {
havePreview--;
add = 0;
+ break;
}
}
if (add == 1) {
+ GNUNET_ASSERT(md->items[i].data != NULL);
ret->data.ksk.keywords[i-havePreview]
= STRDUP(md->items[i].data);
}
@@ -671,7 +678,6 @@
for (i=0;i<count;i++)
ret->data.ksk.keywords[i] = STRDUP(keyword[i]);
return ret;
-
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r1226 - GNUnet/src/applications/fs/ecrs,
grothoff <=