• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
A problematic combination of malloc and getCharacters.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

A problematic combination of malloc and getCharacters.


  • Subject: A problematic combination of malloc and getCharacters.
  • From: deepak gopal <email@hidden>
  • Date: Thu, 25 Oct 2007 04:28:12 +0530 (IST)

Hi

The method performChange would run a script which would modify a plist.

When the control reaches line 12 I get this message "/: /: is a directory" in the run log and when I check in the debugger I find that plistScript and garage have "/" as the value. So I know where the problem is but dont' know what's causing it or what the solution is.

There is no problem with the authorization or with the paths copyPlistScript_ (/tmp/script) or garage_ (/tmp/garage)

I assume that the memory allocation in line 4 and line 6 would give the same result.

Can someone guide me?

1 - (BOOL)performChange  {
2  char **plistArgs = (char **) malloc(3 *sizeof(char*));
3  NSString *shell = @"/bin/sh";

4  char *plistScript = (char *) malloc([copyPlistScript_ length]*sizeof(unichar));
5  [copyPlistScript_ getCharacters:(unichar *) plistScript];

6  char *garage = (char *) malloc([garage_ lengthOfBytesUsingEncoding:NSUnicodeStringEncoding]);
7  [garage_ getCharacters:(unichar *) garage];

8  plistArgs[0] = plistScript;
9  plistArgs[1] = garage;
10 plistArgs[2] = NULL;

12 OSStatus status = AuthorizationExecuteWithPrivileges(authRef_, [shell UTF8String], 0, plistArgs, NULL);

13  if ((status == errAuthorizationCanceled) || (status != errAuthorizationSuccess)) {
14    NSLog(@"Desktop Break Change: Authorization failed when installing new configuration plists.");
15    return NO;
16 }

17  free(plistScript);
18  free(garage);
19 free(plistArgs);
20}




      Why delete messages? Unlimited storage is just a click away. Go to http://help.yahoo.com/l/in/yahoo/mail/yahoomail/tools/tools-08.html
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: A problematic combination of malloc and getCharacters.
      • From: "Shawn Erickson" <email@hidden>
    • Re: A problematic combination of malloc and getCharacters.
      • From: Aki Inoue <email@hidden>
    • Re: A problematic combination of malloc and getCharacters.
      • From: "stephen joseph butler" <email@hidden>
  • Prev by Date: XQuery string help
  • Next by Date: Re: Activating Quit Menu with a Modal Window
  • Previous by thread: Re: XQuery string help
  • Next by thread: Re: A problematic combination of malloc and getCharacters.
  • Index(es):
    • Date
    • Thread