diff --git a/mozilla/nsprpub/pr/src/io/prlayer.c b/mozilla/nsprpub/pr/src/io/prlayer.c index 7519cd9f021..faec9095dc0 100644 --- a/mozilla/nsprpub/pr/src/io/prlayer.c +++ b/mozilla/nsprpub/pr/src/io/prlayer.c @@ -566,6 +566,10 @@ PR_IMPLEMENT(PRFileDesc*) PR_PopIOLayer(PRFileDesc *stack, PRDescIdentity id) *stack = *extract; *extract = copy; stack->higher = NULL; + if (stack->lower) { + PR_ASSERT(stack->lower->higher == extract); + stack->lower->higher = stack; + } } else if ((PR_IO_LAYER_HEAD == stack->identity) && (extract == stack->lower) && (extract->lower == NULL)) { /* diff --git a/mozilla/nsprpub/pr/tests/pushtop.c b/mozilla/nsprpub/pr/tests/pushtop.c index bd09930ff18..621a7c7248f 100644 --- a/mozilla/nsprpub/pr/tests/pushtop.c +++ b/mozilla/nsprpub/pr/tests/pushtop.c @@ -48,6 +48,17 @@ int main() top = PR_PopIOLayer(fd, topId); top->dtor(top); + + middle = fd; + bottom = middle->lower; + + /* Verify that the higher pointer is correct. */ + if (bottom->higher != middle) { + fprintf(stderr, "bottom->higher is wrong\n"); + fprintf(stderr, "FAILED\n"); + exit(1); + } + middle = PR_PopIOLayer(fd, middleId); middle->dtor(middle); if (fd->identity != bottomId) {