benluteijn / redis

Automatically exported from code.google.com/p/redis
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

"sdsMakeRoomFor" CAN'T be used in "sdscpylen" #124

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. create a file "test.c", code:

#include "sds.h"
#include <stdio.h>

int main(int argc, char *argv[])
{
        sds s = sdsnewlen(0, 10);
        // sdshdr * sh = (void *) (s - sizeof(struct sdshdr));

        s = sdscpy(s, "12345");
        printf("%s, %d, %d, %p\n", s, sdslen(s), sdsavail(s), s);

        s = sdscpy(s, "1234567890abc");
        printf("%s, %d, %d, %p\n", s, sdslen(s), sdsavail(s), s);

        return 0;
}

2. compile and execute it:

gcc -o test test.c zmalloc.c sds.c && echo $? && ./test

3. result (for example):

0
12345, 5, 5, 0x804b014
1234567890abc, 13, -3, 0x804b014

What is the expected output? What do you see instead?

What version of the product are you using? On what operating system?
1.1.93

Please provide any additional information below.

Original issue reported on code.google.com by hsh...@gmail.com on 17 Dec 2009 at 9:33

GoogleCodeExporter commented 9 years ago
Thanks fixed. Will close the issue if you can confirm this too.

Cheers,
Salvatore

p.s. Redis was not using this function so it's safe.

Original comment by anti...@gmail.com on 18 Dec 2009 at 10:29

GoogleCodeExporter commented 9 years ago
You're welcome. I think it's OK, very smart.

Original comment by hsh...@gmail.com on 18 Dec 2009 at 2:32

GoogleCodeExporter commented 9 years ago

Original comment by anti...@gmail.com on 23 Aug 2010 at 4:17