netpbm/netpbm-pnmsmooth-segfault.patch
2009-12-08 09:18:42 +00:00

67 lines
1.8 KiB
Diff

diff -up netpbm-10.47.04/editor/pnmsmooth.c.pnmsmooth-segfault netpbm-10.47.04/editor/pnmsmooth.c
--- netpbm-10.47.04/editor/pnmsmooth.c.pnmsmooth-segfault 2009-10-21 13:38:57.000000000 +0200
+++ netpbm-10.47.04/editor/pnmsmooth.c 2009-03-23 07:55:01.000000000 +0100
@@ -23,12 +23,12 @@
#include <unistd.h>
#include <string.h>
#include <errno.h>
+#include <sys/wait.h>
#include "pm_c_util.h"
#include "mallocvar.h"
#include "shhopt.h"
#include "nstring.h"
-#include "pm_system.h"
#include "pnm.h"
@@ -176,6 +176,38 @@ writeConvolutionImage(FILE * const
+static void
+runPnmconvol(const char * const inputFilespec,
+ const char * const convolutionImageFilespec) {
+
+ /* fork a Pnmconvol process */
+ pid_t rc;
+
+ rc = fork();
+ if (rc < 0)
+ pm_error("fork() failed. errno=%d (%s)", errno, strerror(errno));
+ else if (rc == 0) {
+ /* child process executes following code */
+
+ execlp("pnmconvol",
+ "pnmconvol", convolutionImageFilespec, inputFilespec,
+ NULL);
+
+ pm_error("error executing pnmconvol command. errno=%d (%s)",
+ errno, strerror(errno));
+ } else {
+ /* This is the parent */
+ pid_t const childPid = rc;
+
+ int status;
+
+ /* wait for child to finish */
+ while (wait(&status) != childPid);
+ }
+}
+
+
+
int
main(int argc, char ** argv) {
@@ -200,8 +232,7 @@ main(int argc, char ** argv) {
if (cmdline.dump) {
/* We're done. Convolution image is in user's file */
} else {
- pm_system_lp("pnmconvol", NULL, NULL, NULL, NULL,
- tempfileName, cmdline.inputFilespec, NULL);
+ runPnmconvol(cmdline.inputFilespec, tempfileName);
unlink(tempfileName);
strfree(tempfileName);