[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r13634: Fix assertion when searching for a string in an empty chunk. (in tor/trunk: . src/or)



Author: nickm
Date: 2008-02-20 18:58:48 -0500 (Wed, 20 Feb 2008)
New Revision: 13634

Modified:
   tor/trunk/
   tor/trunk/src/or/buffers.c
Log:
 r18283@catbus:  nickm | 2008-02-20 18:58:31 -0500
 Fix assertion when searching for a string in an empty chunk.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r18283] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: tor/trunk/src/or/buffers.c
===================================================================
--- tor/trunk/src/or/buffers.c	2008-02-20 23:38:57 UTC (rev 13633)
+++ tor/trunk/src/or/buffers.c	2008-02-20 23:58:48 UTC (rev 13634)
@@ -1021,15 +1021,19 @@
   int pos;
   tor_assert(out);
   if (out->chunk) {
-    if (!(out->pos < (off_t)out->chunk->datalen)) {
-      log_warn(LD_BUG, "About to assert. %p, %d, %d, %p, %d.",
-               out, (int)out->pos,
-               (int)out->chunk_pos, out->chunk,
-               out->chunk?(int)out->chunk->datalen : (int)-1
-               );
+    if (out->chunk->datalen) {
       /*XXXX020 remove this once the bug it detects is fixed. */
+      if (!(out->pos < (off_t)out->chunk->datalen)) {
+        log_warn(LD_BUG, "About to assert. %p, %d, %d, %p, %d.",
+                 out, (int)out->pos,
+                 (int)out->chunk_pos, out->chunk,
+                 out->chunk?(int)out->chunk->datalen : (int)-1
+                 );
+      }
+      tor_assert(out->pos < (off_t)out->chunk->datalen);
+    } else {
+      tor_assert(out->pos == 0);
     }
-    tor_assert(out->pos < (off_t)out->chunk->datalen);
   }
   pos = out->pos;
   for (chunk = out->chunk; chunk; chunk = chunk->next) {