~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzleslap.cc

  • Committer: Monty Taylor
  • Date: 2008-12-09 04:10:34 UTC
  • mto: This revision was merged to the branch mainline in revision 670.
  • Revision ID: monty@inaugust.com-20081209041034-2uepslabk0hi3shh
Fixed strdup return checking in client/

Show diffs side-by-side

added added

removed removed

Lines of Context:
740
740
    if (argument)
741
741
    {
742
742
      char *start= argument;
743
 
      free(opt_password);
744
 
      opt_password= strdup(argument);
 
743
      if (opt_password)
 
744
        free(opt_password);
 
745
      opt_password = strdup(argument);
 
746
      if (opt_password == NULL)
 
747
      {
 
748
        fprintf(stderr, "Memory allocation error while copying password. "
 
749
                        "Aborting.\n");
 
750
        exit(ENOMEM);
 
751
      }
745
752
      while (*argument) *argument++= 'x';    /* Destroy argument */
746
753
      if (*start)
747
754
        start[1]= 0;        /* Cut length of argument */
1710
1717
    memset(primary_keys, 0, (sizeof(char *) * primary_keys_number_of));
1711
1718
    /* Yes, we strdup a const string to simplify the interface */
1712
1719
    primary_keys[0]= strdup("796c4422-1d94-102a-9d6d-00e0812d");
 
1720
    if (primary_keys[0] == NULL)
 
1721
    {
 
1722
      fprintf(stderr, "Memory Allocation error in option processing\n");
 
1723
      exit(1);
 
1724
    }
1713
1725
  }
1714
1726
  else
1715
1727
  {
1740
1752
      row= drizzle_fetch_row(result);
1741
1753
      for (counter= 0; counter < primary_keys_number_of;
1742
1754
           counter++, row= drizzle_fetch_row(result))
 
1755
      {
1743
1756
        primary_keys[counter]= strdup(row[0]);
 
1757
        if (primary_keys[counter] == NULL)
 
1758
        {
 
1759
          fprintf(stderr, "Memory Allocation error in option processing\n");
 
1760
          exit(1);
 
1761
        }
 
1762
      }
1744
1763
    }
1745
1764
 
1746
1765
    drizzle_free_result(result);
2278
2297
 
2279
2298
    tmp->length= strlen(buffer);
2280
2299
    tmp->string= strdup(buffer);
 
2300
    if (tmp->string == NULL)
 
2301
    {
 
2302
      fprintf(stderr,"Error allocating memory while parsing options\n");
 
2303
      exit(1);
 
2304
    }
2281
2305
 
2282
2306
    if (isspace(*begin_ptr))
2283
2307
      begin_ptr++;