hawq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kavinderd <...@git.apache.org>
Subject [GitHub] incubator-hawq pull request: HAWQ-644. Account for '\0' when dispa...
Date Fri, 15 Apr 2016 02:25:50 GMT
Github user kavinderd commented on a diff in the pull request:

    --- Diff: src/backend/cdb/cdbquerycontextdispatching.c ---
    @@ -779,21 +779,24 @@ static void
     RebuildNamespace(QueryContextInfo *cxt)
    +	MemoryContext oldContext;
     	int len;
     	char buffer[4], *binary;
    +	oldContext = MemoryContextSwitchTo(MessageContext);
     	ReadData(cxt, buffer, sizeof(buffer), TRUE);
     	len = (int) ntohl(*(uint32 *) buffer);
     	binary = palloc(len);
     	if(ReadData(cxt, binary, len, TRUE))
    -		StringInfoData buffer;
    -		initStringInfoOfString(&buffer, binary, len);
    -		dfs_address = strdup(buffer.data);
    +		dfs_address = pstrdup(binary);
    --- End diff --
    In the definition of `pstrdup` it states 
     * MemoryContextStrdup
     *		Like strdup(), but allocate from the specified context
    I chose to use the intermediary `binary` so that if there is an error `dfs_address` is
not set with any data, but your point for not using `binary` at all is valid.
    We are aware that we should `pfree` even with MemoryContext, but we need the `dfs_address`
for the lifetime of each query so this is the simplest & safest means of doing so with
the time given

If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.

View raw message