8000 Minor fixes in _macosx.m by jkseppan · Pull Request #2994 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Minor fixes in _macosx.m #2994

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

Merged
merged 2 commits into from
Apr 22, 2014
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Initialize the states array with calloc in _macosx.m
To silence a warning about garbage data from the clang
static analyzer. Also check the calloc return value.
  • Loading branch information
jkseppan committed Apr 19, 2014
commit dbb80f4be2d8045a25b1c1bfd1c5f428346955e9
8 changes: 6 additions & 2 deletions src/_macosx.m
8073
Original file line number Diff line number Diff line change
Expand Up @@ -4489,7 +4489,12 @@ -(void)save_figure:(id)sender
NSMenu* menu = [button menu];
NSArray* items = [menu itemArray];
unsigned int n = [items count];
int* states = malloc(n*sizeof(int));
int* states = calloc(n, sizeof(int));
if (!states)
{
PyErr_SetString(PyExc_RuntimeError, "calloc failed");
return NULL;
}
int i;
unsigned int m = 0;
NSEnumerator* enumerator = [items objectEnumerator];
Expand All @@ -4504,7 +4509,6 @@ -(void)save_figure:(id)sender
states[i] = 1;
m++;
}
else states[i] = 0;
}
int j = 0;
PyObject* list = PyList_New(m);
Expand Down
0