Skip to content

Commit

Permalink
merge newpkg->provides even when oldpkg->provides existed
Browse files Browse the repository at this point in the history
* introduced in http://code.google.com/p/opkg/source/diff?spec=svn277&r=277&format=side&path=/trunk/libopkg/pkg.c
* the problem happens when oldpkg provide 1 and newpkg provide 2
  provides_count is merged to 2, but oldpkg->provides has only 1 entry
  causing SIGSEGV:
  pkg_formatted_field (fp=fp@entry=0x1444ce0, pkg=pkg@entry=0x120c620, field=<optimized out>, field@entry=0x7ffff7bd2abe "Provides") at pkg.c:739
  739                           fprintf(fp, "%s %s", i == 1 ? "" : ",",
  (gdb) bt
  #0  pkg_formatted_field (fp=fp@entry=0x1444ce0, pkg=pkg@entry=0x120c620, field=<optimized out>, field@entry=0x7ffff7bd2abe "Provides") at pkg.c:739
  #1  0x00007ffff7bc32fc in pkg_print_status (pkg=0x120c620, file=0x1444ce0) at pkg.c:887
  #2  0x00007ffff7bbff59 in opkg_conf_write_status_files () at opkg_conf.c:400
  #3  0x00007ffff7bbad8a in write_status_files_if_changed () at opkg_cmd.c:65
  #4  0x00007ffff7bbb73e in opkg_upgrade_cmd (argc=<optimized out>, argv=<optimized out>) at opkg_cmd.c:577
  #5  0x00007ffff7bbbcc2 in opkg_cmd_exec (cmd=cmd@entry=0x7ffff7dda080, argc=argc@entry=1, argv=argv@entry=0x7fffffffe768) at opkg_cmd.c:1319
  #6  0x000000000040165f in main (argc=3, argv=0x7fffffffe758) at opkg-cl.c:377

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
  • Loading branch information
shr-project committed Sep 19, 2012
1 parent f434078 commit 3340b12
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions libopkg/pkg.c
Expand Up @@ -377,10 +377,8 @@ pkg_merge(pkg_t *oldpkg, pkg_t *newpkg)
oldpkg->provides_count = newpkg->provides_count;
newpkg->provides_count = 0;

if (!oldpkg->provides) {
oldpkg->provides = newpkg->provides;
newpkg->provides = NULL;
}
oldpkg->provides = newpkg->provides;
newpkg->provides = NULL;
}

if (!oldpkg->conflicts_count) {
Expand Down

0 comments on commit 3340b12

Please sign in to comment.