don't rely on realloc() working on NULL
authorAndrew Tridgell <tridge@samba.org>
Sun, 6 Apr 2003 12:28:00 +0000 (12:28 +0000)
committerAndrew Tridgell <tridge@samba.org>
Sun, 6 Apr 2003 12:28:00 +0000 (12:28 +0000)
(This used to be commit bd00355c1d5ca4ce77fa28c53ea46834365f22d7)

source3/lib/charcnv.c

index 42cba334839b8b671392b931460c242f16617513..ad39a6e5dc9f8a9c3cc67d7de3dbd40ec11c3d91 100644 (file)
@@ -214,14 +214,14 @@ size_t convert_string_allocate(charset_t from, charset_t to,
        outbuf = NULL;
 convert:
        destlen = destlen * 2;
-       ob = (char *)realloc(outbuf, destlen);
+       ob = (char *)Realloc(outbuf, destlen);
        if (!ob) {
                DEBUG(0, ("convert_string_allocate: realloc failed!\n"));
                SAFE_FREE(outbuf);
                return (size_t)-1;
-       }
-       else
+       } else {
                outbuf = ob;
+       }
        i_len = srclen;
        o_len = destlen;
        retval = smb_iconv(descriptor,