Ups, sorry. Uploaded.
Anton On Tue, Jan 18, 2011 at 5:05 PM, Niels Thykier <[email protected]> wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA256 > > On 2011-01-18 12:15, Anton Gladky wrote: >> Hi, Niels, >> >> I have re-uploaded that. >> >> Thanks. >> >> Anton >> >> >> >> >> On Tue, Jan 18, 2011 at 10:44 AM, Niels Thykier <[email protected]> wrote: >> On 2011-01-17 22:04, Anton Gladky wrote: >>>>> Hi, Niels, >>>>> >> >> Hey >> >>>>> I have uploaded a new version of rman. Could you not, please, have a look? >>>>> It seems, that I have fixed all issues, which were suggested by you. >>>>> >> >> Sure; I have a question to the realloc replacement. It seems like your >> replacement will be unable to handle if there was not enough memory in >> the first iteration. >> >> @@ -4615,10 +4615,10 @@ char * >> filesuck(FILE *in) { >> const int inc=1024*100; /* [...] */ >> int len=0,cnt; >> - char *file = malloc(1); /*[...] */ >> + char *file; >> >> do { >> - file = realloc(file, len+inc+1); /* w[...] */ >> + file = malloc(len+inc+1); /* [...] */ >> cnt = fread(&file[len], 1, inc, in); >> len+=cnt; >> } while (cnt==inc); >> ---- >> >> I believe the following pattern can be used to solve the original problem. >> >> char *tmp = realloc(file, len + inc + 1); >> if(!tmp) { free(file); <fail-in-a-sane-way>; } >> file = tmp; >> >>>>> [...] > > Better, but it is still lacking the "<fail-in-a-sane-way>" part :) > > Right now it will free file and continue, leading to a null pointer > dereference when it calls fread(). You should be able to use > > fprintf(stderr, "Out of memory\n"); > exit(EXIT_FAILURE); > > as a sane way to fail. > > ~Niels > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.10 (GNU/Linux) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ > > iQIcBAEBCAAGBQJNNbpYAAoJEAVLu599gGRCZuwP/1qlMa4A8+qEFPeVHh5kv057 > NTZXxHyLqWcHDy/LHVa/1uDjYglo/dvIuQZgZonUS3rGxJMQhS6UaWzCd8eoKCm0 > 0Mm7g+Z0+xsy3Kr5ymhtiOYugCf/RKfQLB3iqzWEeOiVUEn2av5XMUvtqmUhfgKk > sgppTKLYLyMOhaHHzgIA9Hl9UYahOZRGOmb0uFYVr5pQQVY8RpfEHn9OZKQvIrJv > IexJI6rESTCXFitp3HidUQZPD2xZhKhLRlGBKxEw+qXtkP3/QAgowb54eXF3f9mE > LNmzbQkHfqQUCIwBplvNvGx9gm91DRgli135U4pJMdXhaWYxZt1SUgQQ6A3xyF4l > Dy3xWzjnasI+gnvlgwuytiBwCbAdFXU3/d1nR7wO59PtdKf8qN3W/1jue0tfBF0N > 6hqNWejhsLsD0s6qnPd0cKgqV/KWS0wMqAp17Re0RqdieB7dDSoTMwIsd4QsTXVC > GlCPqZnAddIHwBtxQHsFhzfzmlIAY8vEup+MW3iysp4VJJWR2whwY2/LujNNCiWN > Z3YyEZW/chUnIlwN288e4XCh2MtkfUqtyKdEr2zCxtcmZJid5r3SyXHRsnsE0Mes > F1hFclFIVAqfr7IhYPh4FWOUZlRq7vFH06xTPAGXcFrD7NATFLKmWnFfxSrqhgzB > IvaVsw4oyA7TxiKag89R > =50Rw > -----END PGP SIGNATURE----- > -- To UNSUBSCRIBE, email to [email protected] with a subject of "unsubscribe". Trouble? Contact [email protected] Archive: http://lists.debian.org/[email protected]

