Bug Summary

File:obj-scan-build/libftpconn/../../libftpconn/set-type.c
Location:line 59, column 10
Description:Memory is never released; potential leak of memory pointed to by 'type'

Annotated Source Code

1/* Set connection type
2
3 Copyright (C) 1997 Free Software Foundation, Inc.
4
5 Written by Miles Bader <miles@gnu.ai.mit.edu>
6
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2, or (at
10 your option) any later version.
11
12 This program is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
20
21#include <unistd.h>
22#include <errno(*__errno_location ()).h>
23#include <string.h>
24
25#include <ftpconn.h>
26#include "priv.h"
27
28/* Set the ftp connection type of CONN to TYPE, or return an error. */
29error_t
30ftp_conn_set_type (struct ftp_conn *conn, const char *type)
31{
32 error_t err = 0;
33
34 if (! type)
1
Assuming 'type' is non-null
2
Taking false branch
35 return EINVAL((0x10 << 26) | ((22) & 0x3fff));
36
37 if (!conn->type || strcmp (type, conn->type) != 0)
38 {
39 type = strdup (type);
3
Memory is allocated
40 if (! type)
4
Assuming 'type' is non-null
5
Taking false branch
41 err = ENOMEM((0x10 << 26) | ((12) & 0x3fff));
42 else
43 {
44 int reply;
45 error_t err = ftp_conn_cmd (conn, "type", type, &reply, 0);
46
47 if (!err && reply != REPLY_OK200 && reply != REPLY_CLOSED421)
6
Assuming 'err' is not equal to 0
48 err = unexpected_reply (conn, reply, 0, 0);
49
50 if (!err || err == EPIPE((0x10 << 26) | ((32) & 0x3fff)))
7
Taking false branch
51 {
52 if (conn->type)
53 free ((char *)conn->type);
54 conn->type = type;
55 }
56 }
57 }
58
59 return err;
8
Memory is never released; potential leak of memory pointed to by 'type'
60}