Skip to content

Commit

Permalink
apply ldo-getxattr-bufsize.patch.txt and refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
hamano committed Oct 20, 2020
1 parent eed4b40 commit 2f4162e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions smbc/context.c
Original file line number Diff line number Diff line change
Expand Up @@ -585,25 +585,27 @@ Context_getxattr (Context *self, PyObject *args)
char *uri = NULL;
char *name = NULL;
char *buffer = NULL;
int ret;
do /*once*/
{
if (!PyArg_ParseTuple(args, "ss", &uri, &name))
break;
const smbc_getxattr_fn fn = smbc_getFunctionGetxattr(self->context);
errno = 0;
const int bufsize = fn(self->context, uri, name, NULL, 0);
if (bufsize < 0)
ret = fn(self->context, uri, name, NULL, 0);
if (ret < 0)
{
pysmbc_SetFromErrno();
break;
} /*if*/
}
const int bufsize = ret + 1;
buffer = (char *)malloc(bufsize);
if (buffer == NULL)
{
PyErr_NoMemory();
break;
} /*if*/
const int ret = fn(self->context, uri, name, buffer, bufsize);
ret = fn(self->context, uri, name, buffer, bufsize);
if (ret < 0)
{
pysmbc_SetFromErrno();
Expand Down

0 comments on commit 2f4162e

Please sign in to comment.