From 3951b5f55066c381f8c399791bb8740b2404700d Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Fri, 6 Mar 2009 08:58:03 +0100 Subject: copy input for dirname(3) (reported by David Mitchell) --- src/ImageMetaData.cxx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ImageMetaData.cxx b/src/ImageMetaData.cxx index 5e0102a..cfa699e 100644 --- a/src/ImageMetaData.cxx +++ b/src/ImageMetaData.cxx @@ -215,8 +215,11 @@ ImageMetaData::save_image_jpgcom(char *in_img, char *out_img) { int status, err = 0; ssize_t n; int tmp_fd; + char *dirbuf; - snprintf(tmpname, sizeof(tmpname), "%s/.gipfelXXXXXX", dirname(out_img)); + dirbuf = strdup(out_img); + snprintf(tmpname, sizeof(tmpname), "%s/.gipfelXXXXXX", dirname(dirbuf)); + free(dirbuf); tmp_fd = mkstemp(tmpname); if (tmp_fd < 0) { perror("mkstemp"); -- cgit v1.2.3