Patch to fix ecpg core dump with nested structure pointer variable

Started by Muhammad Usamaabout 13 years ago2 messages
#1Muhammad Usama
m.usama@gmail.com
2 attachment(s)

Hi

I have bumped in the segmentation fault in ecpg when using pointer to
nested structure variable.

ecpg crash.pgc
Segmentation fault: 11

Please see the attached patch for the fix and test case to reproduce the
scenario.

Thanks
Regards
Muhammad Usama

Attachments:

crash.pgcapplication/octet-stream; name=crash.pgcDownload
ecpg_crash.patchapplication/octet-stream; name=ecpg_crash.patchDownload
diff --git a/src/interfaces/ecpg/preproc/variable.c b/src/interfaces/ecpg/preproc/variable.c
index e08e14a..6ff574b 100644
--- a/src/interfaces/ecpg/preproc/variable.c
+++ b/src/interfaces/ecpg/preproc/variable.c
@@ -100,7 +100,11 @@ find_struct_member(char *name, char *str, struct ECPGstruct_member * members, in
 						}
 						break;
 					case '-':
-						return (find_struct_member(name, end, members->type->u.element->u.members, brace_level));
+						if (members->type->type == ECPGt_array)
+							return (find_struct_member(name, ++end, members->type->u.element->u.members, brace_level));
+						else
+							return (find_struct_member(name, ++end, members->type->u.members, brace_level));
+						break;
 						break;
 					case '.':
 						if (members->type->type == ECPGt_array)
#2Michael Meskes
meskes@postgresql.org
In reply to: Muhammad Usama (#1)
Re: Patch to fix ecpg core dump with nested structure pointer variable

I have bumped in the segmentation fault in ecpg when using pointer to
nested structure variable.
...
Please see the attached patch for the fix and test case to reproduce the
scenario.

Thanks for spotting and fixing this. Patch committed to git.

Michael
--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org
Jabber: michael.meskes at gmail dot com
VfL Borussia! Força Barça! Go SF 49ers! Use Debian GNU/Linux, PostgreSQL

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers