Opened 10 years ago

Closed 7 years ago

#40978 closed defect (fixed)

emacs-app @24.3_1/emacs-mac-app @4.4: memory bug in patch-src_emacs.c.diff

Reported by: takanori@… Owned by: drkp (Dan Ports)
Priority: Normal Milestone:
Component: ports Version: 2.2.0
Keywords: haspatch Cc: humem (humem), cssdev
Port: emacs-app emacs-mac-app

Description

I noticed that there is a minor bug in patch-src_emacs.c.diff.

[patch-src_emacs.c.diff]
...
+  /* Imaxima won't work properly if PATH does not contain the
+     MacPorts directory. The following code is a workaround to
+     avoid this problem. */
+  {
+    char *oldpath = getenv("PATH");
+    if (!oldpath) {oldpath = "";}
+    size_t oldpathsize = strlen(oldpath) + 1;
+    if (!strstr(oldpath, "__PREFIX__/bin")) {
+      char *newpath;
+      size_t newpathsize = oldpathsize + strlen("__PREFIX__/bin:");
+      if ((newpath = (char *)malloc(newpathsize)) != NULL) {
+        strlcpy(newpath, "__PREFIX__/bin:", newpathsize);
+        strlcat(newpath, oldpath, newpathsize);
+        setenv("PATH", newpath, 1);
+        free(newpath);
+      }
+    }
+  }
...

setenv(3) says the string pointed to by the 2nd argument of setenv shouldn't be altered/freed during the application program is running. i.e. The line "free(newpath);" should be commented out.

Attachments (2)

emacs-app.diff (856 bytes) - added by takanori@… 10 years ago.
emacs-mac-app.diff (920 bytes) - added by takanori@… 10 years ago.

Download all attachments as: .zip

Change History (4)

Changed 10 years ago by takanori@…

Attachment: emacs-app.diff added

Changed 10 years ago by takanori@…

Attachment: emacs-mac-app.diff added

comment:1 Changed 7 years ago by drkp (Dan Ports)

Cc: hum@… css@… added
Owner: changed from hum@… to drkp
Status: newassigned

comment:2 Changed 7 years ago by drkp (Dan Ports)

Resolution: fixed
Status: assignedclosed

In 526ab45/macports-ports:

emacs-app(-devel): fix memory bug in patchfile

Closes #40978

Note: See TracTickets for help on using tickets.