Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/db/recno fix bug in previous change (sz should be t...



details:   https://anonhg.NetBSD.org/src/rev/dac97bf0d75e
branches:  trunk
changeset: 792196:dac97bf0d75e
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Dec 25 19:42:23 2013 +0000

description:
fix bug in previous change (sz should be the size of the newly allocated
buffer).

diffstat:

 lib/libc/db/recno/rec_get.c |  14 ++++++--------
 1 files changed, 6 insertions(+), 8 deletions(-)

diffs (44 lines):

diff -r ec65ccb0bfb4 -r dac97bf0d75e lib/libc/db/recno/rec_get.c
--- a/lib/libc/db/recno/rec_get.c       Wed Dec 25 17:24:39 2013 +0000
+++ b/lib/libc/db/recno/rec_get.c       Wed Dec 25 19:42:23 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rec_get.c,v 1.17 2013/12/14 18:04:56 christos Exp $    */
+/*     $NetBSD: rec_get.c,v 1.18 2013/12/25 19:42:23 christos Exp $    */
 
 /*-
  * Copyright (c) 1990, 1993, 1994
@@ -34,7 +34,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: rec_get.c,v 1.17 2013/12/14 18:04:56 christos Exp $");
+__RCSID("$NetBSD: rec_get.c,v 1.18 2013/12/25 19:42:23 christos Exp $");
 
 #include "namespace.h"
 #include <sys/types.h>
@@ -175,7 +175,6 @@
 {
        DBT data;
        recno_t nrec;
-       ptrdiff_t len;
        size_t sz;
        int bval, ch;
        uint8_t *p;
@@ -195,13 +194,12 @@
                                break;
                        }
                        if (sz == 0) {
-                               void *np;
-                               len = p - (uint8_t *)t->bt_rdata.data;
-                               sz = t->bt_rdata.size + 256;
-                               np = realloc(t->bt_rdata.data, sz);
+                               ptrdiff_t len = p - (uint8_t *)t->bt_rdata.data;
+                               size_t tot = t->bt_rdata.size + (sz = 256);
+                               void *np = realloc(t->bt_rdata.data, tot);
                                if (np == NULL)
                                        return (RET_ERROR);
-                               t->bt_rdata.size = sz;
+                               t->bt_rdata.size = tot;
                                t->bt_rdata.data = np;
                                p = (uint8_t *)t->bt_rdata.data + len;
                        }



Home | Main Index | Thread Index | Old Index