Github user ictmalili commented on a diff in the pull request:

    https://github.com/apache/incubator-hawq/pull/835#discussion_r73815574
  
    --- Diff: src/backend/cdb/executormgr.c ---
    @@ -864,29 +864,42 @@ addOneOption(PQExpBufferData *buffer, struct 
config_generic * guc)
                        {
                                struct config_string *sguc = (struct 
config_string *) guc;
                                const char *str = *sguc->variable;
    -                           int                     j,
    -                                                   start,
    -                                                   end;
    -                           char            temp[1024];
    +                           unsigned int     j, start, size;
    +                           char                    *temp;
     
    -                           end = strlen(str);
    +                           size = 256;
    +                           temp = malloc(size + 8);
    +                           if (temp == NULL)
    +                                   ereport(ERROR,
    +                                                   
(errcode(ERRCODE_OUT_OF_MEMORY),
    +                                                    errmsg("out of 
memory")));
     
                                j = 0;
    -                           for (start = 0; start < end; ++start)
    +                           for (start = 0; start < strlen(str); ++start)
                                {
    -                                   if (str[start] == ' ')
    -                                           continue;
    +                                   if (j == size)
    +                                   {
    +                                           size *= 2;
    +                                           temp = realloc(temp, size + 8);
    +                                           if (temp == NULL)
    --- End diff --
    
    What if realloc fail? Will the memory leak?


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to