nano-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Nano-devel] Patch for bug #44950


From: Rishabh Dave
Subject: Re: [Nano-devel] Patch for bug #44950
Date: Tue, 29 Dec 2015 22:09:40 +0530

This is because I run with 'export MALLOC_CHECK_=2'.

So... something is going wrong with your memory allocations.

When you do 'x = charalloc(sizeof(a))', I think you want to do
'x = charalloc(strlen(a) * sizeof(char))'.

Also, you've added a function called strcpyfu(a, b, c, d) that
does the equivalent of strncpy(a, b+c, d-c).  Why not use the
latter?  Furthermore, you only ever call strcpyfu() with c=0,
so it is in fact identical to strncpy().  :|  (Apart from the
zero termination, but the main routine does that anyhow, so...)

The comment of the determine() routine mentions values of
-1 and -2, but the code only ever returns values of zero or
higher.  So... I don't know what was the intention there.



I admit that mistake over the comment was foolish one but for the I
never used C so, efficiently. I will take care of such mistakes next
time. Thank you for putting up with them
 
 
After making the above mentioned changes to your patch,
and adjusting it for whitespace too, it no longer aborts
when I use MALLOC_CHECK_=2 with 'src/nano doc/what'.
However, it still does not do the expected thing when giving
it a nonexistent dir: 'src/nano none/what' still tries to write
a lockfile into 'none/' -- it should not, it should just mention
on the statusbar that 'none' does not exist and skip trying
to write a lockfile.



I checked if patch (improved version you sent) was correct by
copying code into a new program to run it standalone. It runs
successfully. I also applied patch you sent and then used 'make',
it worked. Then I looked up what is MALLOC_CHECK_ , exactly
and set it to 2. It works for './nano none/what' but not for './nano a/b'.
I never trying porting my code over different OS. Maybe it runs only
under my environment which is Ubuntu 14.04.

I have sent a screen dumps (MALLOC_CHECK was untouched then) and the
standalone version of patch hoping it helps.

Attachment: standalone-program-for-patch.c
Description: Text Data

Attachment: before-and-after-applying-patch-to-nano.png
Description: PNG image


reply via email to

[Prev in Thread] Current Thread [Next in Thread]