Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error processing empty memo fields #12

Open
avostrik opened this issue Sep 2, 2014 · 2 comments
Open

Error processing empty memo fields #12

avostrik opened this issue Sep 2, 2014 · 2 comments

Comments

@avostrik
Copy link

avostrik commented Sep 2, 2014

Hi, Kirk,

while importing one of the Russian public databases, I have encountered error:
"A memo record past the end of the memofile was requested"

Root cause is that memo field value is NULL for some records
Here it is proposed patch to fix it.

Best regards,
Andrey

From cf690f6c10e6912c5773d2935293dd6e7be48336 Mon Sep 17 00:00:00 2001
From: Andrey Vostrikov <[email protected]>
Date: Tue, 2 Sep 2014 09:48:01 +0400
Subject: [PATCH] Fixed error in block number calculation during processing of
 memo fields with no data

---
 src/pgdbf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/pgdbf.c b/src/pgdbf.c
index d4da164..600fc11 100644
--- a/src/pgdbf.c
+++ b/src/pgdbf.c
@@ -712,7 +712,7 @@ int main(int argc, char **argv) {
                         memoblocknumber = 0;
                         s = bufoffset;
                         for(i = 0; i < 10; i++) {
-                            if(*s != 32) {
+                            if(*s && *s != 32) {
                                 /* I'm unaware of any non-ASCII
                                  * implementation of XBase. */
                                 memoblocknumber = memoblocknumber * 10 + *s - '0';
--
1.9.1
@kstrauser
Copy link
Owner

Thanks for writing, @avostrik! Would it be possible to send a test database with null memo field values so that I can write tests for it?

@kstrauser
Copy link
Owner

I merged this, thanks! I'd still appreciate a small test file if you can generate one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants