1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-10-01 03:36:26 -04:00

Revert 11e6aa8d97, "Bug 944, SMB: Fix leaks and libsmbclient 3.0.10 compatibility."

Revert commit 11e6aa8d97.
It is not useful to complicate the code to free the memory,
because the process is soon going to exit, and it has inherited
a lot more memory allocations from its parent.

The libsmbclient 3.0.10 compatibility changes are good though.
I'll re-apply them soon enough.
This commit is contained in:
Kalle Olavi Niemitalo 2007-03-05 22:15:45 +02:00 committed by Kalle Olavi Niemitalo
parent e517ef22a9
commit f621ed63b4

View File

@ -185,44 +185,22 @@ sort_and_display_entries(int dir, unsigned char dircolor[])
if (!strcmp(fentry->name, "."))
continue;
/* Preallocate a @table element, but don't increment
* @size yet. This way, we need not explicitly free
* the element if something goes wrong. It may cause
* CHECK_USELESS_REALLOC to complain, though. */
new_entry = mem_alloc(length);
if (fentry->comment) {
char *comment = mem_alloc(fentry->commentlen + 1);
if (comment) memcpy(comment, fentry->comment, fentry->commentlen + 1);
fentry->comment = comment;
}
if (!new_entry)
continue;
new_table = mem_realloc(table, (size + 1) * sizeof(*table));
if (!new_table)
continue;
table = new_table;
new_entry = mem_alloc(length);
if (!new_entry)
continue;
memcpy(new_entry, fentry, length);
/* In libsmbclient 3.0.10, @smbc_dirent.namelen and
* @smbc_dirent.commentlen include the null characters
* (tested with GDB). In libsmbclient 3.0.24, they
* don't. This is related to Samba bug 3030. Adjust
* the lengths to exclude the null characters, so that
* other code need not care. */
if (new_entry->commentlen > 0
&& new_entry->comment[new_entry->commentlen - 1] == '\0')
new_entry->commentlen--;
if (new_entry->namelen > 0
&& new_entry->name[new_entry->namelen - 1] == '\0')
new_entry->namelen--;
if (new_entry->comment) {
/* memacpy appends a null character. */
new_entry->comment = memacpy(new_entry->comment,
new_entry->commentlen);
if (new_entry->comment == NULL) {
mem_free(new_entry);
continue;
}
}
table[size++] = new_entry;
table = new_table;
table[size] = new_entry;
size++;
}
qsort(table, size, sizeof(*table),
(int (*)(const void *, const void *)) compare);