pick now copy the static memory which is later freed.
Also fix the access to uninitialized variable in getthreadid().
Thanks c_14 for reporting.
char *cp;
threadfrom = referens ? referens : msgid;
+ if (!threadfrom) {
+ return NULL;
+ }
start = strchr(threadfrom, '<');
end = strchr(start, '>');
--- /dev/null
+#!/bin/sh
+######################################################
+#
+# Test that the -thread option works.
+#
+######################################################
+
+expected_err=$MH_TEST_DIR/$$.expected_err
+expected_out=$MH_TEST_DIR/$$.expected_out
+actual_err=$MH_TEST_DIR/$$.actual_err
+actual_out=$MH_TEST_DIR/$$.actual_out
+
+# All messages should be go to stdout
+cp `mhpath 5` 5.old
+anno -component 'Message-Id' -text '<testid>' 5 -nodate
+cat > $expected_out <<EOF
+5
+EOF
+# Nothing should to go stderr
+cat /dev/null > $expected_err
+
+pick -thread 5 > $actual_out 2> $actual_err
+mv 5.old `mhpath 5`
+diff -u $expected_err $actual_err
+diff -u $expected_out $actual_out
--- /dev/null
+#!/bin/sh
+######################################################
+#
+# Test that the -thread option works.
+#
+######################################################
+
+expected_err=$MH_TEST_DIR/$$.expected_err
+expected_out=$MH_TEST_DIR/$$.expected_out
+actual_err=$MH_TEST_DIR/$$.actual_err
+actual_out=$MH_TEST_DIR/$$.actual_out
+
+# All messages should be go to stdout
+cat > $expected_out <<EOF
+5
+EOF
+# Nothing should to go stderr
+cat /dev/null > $expected_err
+
+pick -thread 5 > $actual_out 2> $actual_err
+diff -u $expected_err $actual_err
+diff -u $expected_out $actual_out
bd->left = left;
bd->right = right;
- gd->header = "message-id";
+ gd->header = mh_xstrdup("message-id");
snprintf(buf, sizeof(buf), "^[ \t]*<%s>", c);
if(!gcompile(gd, buf)) {
}
gd = right->data;
- gd->header = "references";
+ gd->header = mh_xstrdup("references");
snprintf(buf, sizeof(buf), "^[ \t]*<%s>", c);
if(!gcompile(gd, buf)) {