From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 113696 invoked by alias); 16 Feb 2017 12:37:12 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 113673 invoked by uid 89); 16 Feb 2017 12:37:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 spammy=H*f:sk:69822b2, H*i:sk:69822b2 X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0b-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.158.5) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 16 Feb 2017 12:37:11 +0000 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v1GCSfiB096754 for ; Thu, 16 Feb 2017 07:37:09 -0500 Received: from e06smtp10.uk.ibm.com (e06smtp10.uk.ibm.com [195.75.94.106]) by mx0b-001b2d01.pphosted.com with ESMTP id 28n6ua5hs1-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 16 Feb 2017 07:37:09 -0500 Received: from localhost by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 16 Feb 2017 12:37:07 -0000 Received: from d06dlp03.portsmouth.uk.ibm.com (9.149.20.15) by e06smtp10.uk.ibm.com (192.168.101.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 16 Feb 2017 12:37:05 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id D64151B08072; Thu, 16 Feb 2017 12:40:01 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v1GCb4h510223996; Thu, 16 Feb 2017 12:37:05 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D7BCF4204C; Thu, 16 Feb 2017 12:37:00 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B6E0242042; Thu, 16 Feb 2017 12:37:00 +0000 (GMT) Received: from ThinkPad (unknown [9.152.212.148]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 16 Feb 2017 12:37:00 +0000 (GMT) Date: Thu, 16 Feb 2017 12:37:00 -0000 From: Philipp Rudo To: Pedro Alves Cc: Sergio Durigan Junior , GDB Patches , Luis Machado Subject: Re: [PATCH v3 5/6] Share fork_inferior et al with gdbserver In-Reply-To: <69822b2e-e57e-3608-ed48-3c93842adcca@redhat.com> References: <1482464361-4068-1-git-send-email-sergiodj@redhat.com> <20170208032257.15443-1-sergiodj@redhat.com> <20170208032257.15443-6-sergiodj@redhat.com> <20170216132338.69e7c464@ThinkPad> <69822b2e-e57e-3608-ed48-3c93842adcca@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 17021612-0040-0000-0000-0000032C482A X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17021612-0041-0000-0000-0000242F8A03 Message-Id: <20170216133703.18dfce12@ThinkPad> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-02-16_09:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1612050000 definitions=main-1702160124 X-IsSubscribed: yes X-SW-Source: 2017-02/txt/msg00438.txt.bz2 On Thu, 16 Feb 2017 12:26:05 +0000 Pedro Alves wrote: > On 02/16/2017 12:23 PM, Philipp Rudo wrote: > > On Wed, 15 Feb 2017 17:28:24 +0000 > > Pedro Alves wrote: > > > > [...] > > > >>> + ret.erase (ret.end () - 1); > >>> + > >>> + initialized_p = 1; > >>> } > >>> > >>> + return (char *) ret.c_str (); > >> > >> Can the function return const instead? > > > > No it can't. The function must either return the std::string or > > xstrdup (ret.c_str ()). 'std::string ret' is declared for this > > function only. Thus it is freed once the function returns > > ret.c_str () leaving a dangling pointer. > > Nope, it's not freed on return. You've missed the "static": > > char * > get_exec_wrapper (void) > { > char **new_argv = argv; > static std::string ret; > ^^^^^^ Indeed I did... Sorry for the spam Philipp